Skip to content

Commit 541fd45

Browse files
V-FEXrtjoncardasis
authored andcommitted
Send an editingDidEnd action when either slider or handle is let go
Updated podspec for changes as well.
1 parent a0cc389 commit 541fd45

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

ChromaColorPicker.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "ChromaColorPicker"
3-
s.version = "1.4"
3+
s.version = "1.4.1"
44
s.summary = "An intuitive iOS color picker built in Swift."
55

66
s.description = <<-DESC
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
1111
s.license = { :type => "MIT", :file => "LICENSE" }
1212
s.author = "Jonathan Cardasis"
1313
s.platform = :ios, "8.0"
14-
s.source = { :git => "https://github.com/joncardasis/ChromaColorPicker.git", :tag => "1.4" }
14+
s.source = { :git => "https://github.com/joncardasis/ChromaColorPicker.git", :tag => "1.4.1" }
1515
s.source_files = "ChromaColorPicker", "ChromaColorPicker/*.swift"
1616

1717
end

ChromaColorPicker/ChromaColorPicker.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ open class ChromaColorPicker: UIControl {
9393
shadeSlider = ChromaShadeSlider()
9494
shadeSlider.delegate = self
9595
self.layoutShadeSlider()
96-
96+
shadeSlider.addTarget(self, action: #selector(ChromaColorPicker.sliderEditingDidEnd(_:)), for: .editingDidEnd)
9797

9898
/* Add components to view */
9999
self.layer.addSublayer(handleLine)
@@ -189,6 +189,7 @@ open class ChromaColorPicker: UIControl {
189189

190190
private func executeHandleShrinkAnimation(){
191191
self.sendActions(for: .touchUpInside)
192+
self.sendActions(for: .editingDidEnd)
192193
UIView.animate(withDuration: 0.15, delay: 0, options: .curveEaseOut, animations: { () -> Void in
193194
self.handleView.transform = CGAffineTransform(scaleX: 1, y: 1)
194195
}, completion: nil)
@@ -231,6 +232,9 @@ open class ChromaColorPicker: UIControl {
231232
delegate?.colorPickerDidChooseColor(self, color: sender.color) //Delegate call
232233
}
233234

235+
func sliderEditingDidEnd(_ sender: ChromaShadeSlider){
236+
self.sendActions(for: .editingDidEnd)
237+
}
234238

235239
//MARK: - Drawing
236240
override open func draw(_ rect: CGRect) {

ChromaColorPicker/ChromaShadeSlider.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ open class ChromaShadeSlider: UIControl {
178178
return true
179179
}
180180

181+
override open func endTracking(_ touch: UITouch?, with event: UIEvent?) {
182+
self.sendActions(for: .editingDidEnd)
183+
}
184+
181185
func doubleTapRecognized(_ recognizer: UITapGestureRecognizer){
182186
let location = recognizer.location(in: self)
183187
guard handleView.frame.contains(location) else {

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
![Platform](https://img.shields.io/badge/platform-iOS-lightgray.svg)
44
![License](https://img.shields.io/badge/license-MIT-blue.svg)
55
![Carthage](https://img.shields.io/badge/Carthage-✔-green.svg)
6-
![CocoaPods](https://img.shields.io/badge/CocoaPods-1.4-green.svg)
6+
![CocoaPods](https://img.shields.io/badge/CocoaPods-1.4.1-green.svg)
77

88
An intuitive iOS color picker built in Swift.
99

@@ -96,6 +96,8 @@ Sub-Components can be hidden and customized to the preferred liking.
9696

9797
`.touchDragInside` -> called when the handle has moved by a drag action
9898

99+
`.editingDidEnd` -> called when either the handle is let go or slider is let go
100+
99101

100102
## Additional Info
101103
Check out the [Wiki](https://github.com/joncardasis/ChromaColorPicker/wiki/Challenges-and-Solutions) if you're interested in reading into how the color wheel was created.

0 commit comments

Comments
 (0)