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
ColorPreviewable
protocol. - Customizable
DefaultPreviewView
that supports custom animation duration, scale, size, and offset. - Black and white colors are now accessible from within the slider (#15).
- Settable
color
property 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.
previewEnabled
has been replaced by apreviewView
parameter in the initializer. Passnil
for 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
). -
previewDimension
has 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))
-
previewOffset
is now a property on theDefaultPreviewView
and designates the offset from the center of theColorSlider
rather 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
DefaultPreviewView
that can be customized. Alternatively, you can now subclassDefaultPreviewView
or implementColorPreviewable
in aUIView
subclass and pass it into theColorSlider
initializer to use a completely custom preview.
Appearance
-
borderWidth
has been replaced bygradientView.layer.borderWidth
. -
borderColor
has been replaced bygradientView.layer.borderColor
and now requires aCGColor
instead of aUIColor
. -
cornerRadius
has been replaced bygradientView.layer.cornerRadius
instead. -
setsCornerRadiusAutomatically
has been replaced bygradientView.automaticallyAdjustsCornerRadius
-
orientation
is 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.