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 moreColorSlideron 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
offsetAmountandside. This value is calculated automatically incalculateOffsetand 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
sideThe side of the
ColorSliderto show on. Defaults to.left.
-
Set the
backgroundColorofcolorViewto the newcolor.Declaration
Swift
public func colorChanged(to color: UIColor)Parameters
colorThe new color.
-
Animating to the
CGAffineTransformwith:- Translation:
offset- Scale:
scaleAmounts[state]Seealso
offsetAmountSeealso
scaleAmountsSeealso
offsetDeclaration
Swift
public func transition(to state: PreviewState)Parameters
stateThe new state to transition to.
- Translation:
View on GitHub
Install in Dash
DefaultPreviewView Class Reference