ColorSliderPreviewing

public protocol ColorSliderPreviewing

A protocol defining callback methods for a ColorSlider preview view.

To create a custom preview view, create a UIView subclass and implement ColorSliderPreviewing. Then, create an instance of your custom preview view and pass it to the ColorSlider initializer. As a user drags their finger, ColorSlider will automatically set your preview view’s center to the point closest to the touch, centered along the axis perpendicular to the ColorSlider‘s orientation.

If autoresizesSubviews is true (the default value on all UIViews) on your ColorSlider, your preview view will also be automatically resized when its center point is being set. To disable resizing your preview, set the autoresizesSubviews property on your ColorSlider to false.

  • Called when the color of the slider changes, so the preview can respond correctly.

    Declaration

    Swift

    func colorChanged(to color: UIColor)

    Parameters

    color

    The newly selected color.

  • Called when the preview changes state and should update its appearance appropriately. Since ColorSlider sets the center of your preview automatically, you should use your view’s transform to adjust or animate most changes. See DefaultPreviewView for an example.

    Declaration

    Swift

    func transition(to state: PreviewState)

    Parameters

    state

    The new state of the preview view.