DefaultPreviewView
public class DefaultPreviewView: UIView
The default preview view of a ColorSlider
.
Appears to the given side
of the associated ColorSlider
at the point of the currently
selected color with an offset of offsetAmount
and a scale given by scaleAmounts
for a given state.
You can subclass this class and pass it as a preview to ColorSlider
to customize its appearance or animation.
You may also create your own custom UIView
and conform to the PreviewView
protocol and pass that to ColorSlider
‘s initializer.
-
The animation duration when showing the preview. Defaults to
0.15
.Declaration
Swift
public var animationDuration: TimeInterval = 0.15
-
The side of the
See moreColorSlider
on which to show the preview view.Declaration
Swift
public enum Side
-
The side of the ColorSlider that the preview should show on. Defaults to
.left
.Declaration
Swift
public var side: Side
-
The scale of the slider for each preview state. Defaults to:
.inactive
:1
.activeFixed
:1.2
.active
:1.6
Declaration
Swift
public var scaleAmounts: [PreviewState: CGFloat] = [.inactive: 1.0,
-
The number of points to offset the preview view from the slider when the state is set to
.active
. Defaults to50
.Declaration
Swift
public var offsetAmount: CGFloat = 50
-
The actual offset of the preview view, calculated from
offsetAmount
andside
. This value is calculated automatically incalculateOffset
and should only be modified externally by subclasses.Declaration
Swift
public var offset: CGPoint
-
The view that displays the current color as its
backgroundColor
.Declaration
Swift
public let colorView: UIView = UIView()
-
Enable haptics on iPhone 7 and above for state transitions to/from
.activeFixed
. Defaults totrue
.Declaration
Swift
public var hapticsEnabled: Bool = true
-
Initialize with a specific side.
Declaration
Swift
required public init(side: Side = .left)
Parameters
side
The side of the
ColorSlider
to show on. Defaults to.left
.
-
Set the
backgroundColor
ofcolorView
to the newcolor
.Declaration
Swift
public func colorChanged(to color: UIColor)
Parameters
color
The new color.
-
Animating to the
CGAffineTransform
with:- Translation:
offset
- Scale:
scaleAmounts[state]
Seealso
offsetAmount
Seealso
scaleAmounts
Seealso
offset
Declaration
Swift
public func transition(to state: PreviewState)
Parameters
state
The new state to transition to.
- Translation: