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 ColorSlider on which to show the preview view.

    See more

    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 to 50.

    Declaration

    Swift

    public var offsetAmount: CGFloat = 50
  • The actual offset of the preview view, calculated from offsetAmount and side. This value is calculated automatically in calculateOffset 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 to true.

    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.

  • Calculate the offset of the preview view when offset or side are set.

    Declaration

    Swift

    public func calculateOffset()