Releases: gizmosachin/ColorSlider
Support Swift 5.0
Fix internal initializer
4.0
ColorSlider 4.0 is a major new version that supports full customization of the preview view and selecting black and white colors from within the slider. The project has been fully rewritten to be more simple and customizable, with a much cleaner API surface and view hierarchy. The major new features include:
- Full preview view customization via the
ColorPreviewableprotocol. - Customizable
DefaultPreviewViewthat supports custom animation duration, scale, size, and offset. - Black and white colors are now accessible from within the slider (#15).
- Settable
colorproperty that updates the current color on the slider (#19). - New demo project that no longer requires external dependencies or Cocoapods.
- Swift 4
Breaking Changes
Live Preview
-
The color preview is now enabled by default.
previewEnabledhas been replaced by apreviewViewparameter in the initializer. Passnilfor this property to disable the preview. -
Preview behavior has changed. A minimized version of the preview now shows on top of ColorSlider, even when touches are not being tracked, indicating the color currently selected (given by
color). -
previewDimensionhas been replaced and the default preview view now resizes based on the size of the slider. To manually set the preview size:colorSlider.autoresizesSubviews = false colorSlider.previewView.bounds = CGRect(origin: .zero, size: CGSize(44, 44))
-
previewOffsetis now a property on theDefaultPreviewViewand designates the offset from the center of theColorSliderrather than the edge (as it did before):if let previewView = colorSlider.previewView as? DefaultPreviewView { previewView.offsetAmount = 60 }
-
To hide the minimized preview and mimic the behavior of the old preview view:
if let previewView = colorSlider.previewView as? DefaultPreviewView { previewView.scaleAmounts[.inactive] = 0.001 }
-
There are several other properties on the
DefaultPreviewViewthat can be customized. Alternatively, you can now subclassDefaultPreviewViewor implementColorPreviewablein aUIViewsubclass and pass it into theColorSliderinitializer to use a completely custom preview.
Appearance
-
borderWidthhas been replaced bygradientView.layer.borderWidth. -
borderColorhas been replaced bygradientView.layer.borderColorand now requires aCGColorinstead of aUIColor. -
cornerRadiushas been replaced bygradientView.layer.cornerRadiusinstead. -
setsCornerRadiusAutomaticallyhas been replaced bygradientView.automaticallyAdjustsCornerRadius -
orientationis no longer settable after initialization. Pass the orientation in the initializer instead.
3.0.1
3.0
2.5
2.4
2.3
Clean up internal source, remove storyboards from sample project.
1.1
- supports editing appearance properties within Interface Builder (see Main.storyboard in example project)
- padding is now
edgeInsets(and now works correctly) - ability to add shadow
- cleaned up code and sample project
1.0
Supports changing color hue when dragging inside the bounds of the ColorSlider and modifying lightness when dragging outside its bounds.