Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2d47f2f17b | |||
| aea70afcce |
@@ -7,7 +7,7 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
48A9BFBF20BED26800AC149A /* RAScrollablePickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48A9BFBE20BED26800AC149A /* RAScrollablePickerView.swift */; };
|
||||
48D1A6E921160D36007221D1 /* RAScrollablePickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48D1A6E821160D36007221D1 /* RAScrollablePickerView.swift */; };
|
||||
6908F4291B500AE500A410E2 /* WindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6908F4281B500AE500A410E2 /* WindowController.swift */; };
|
||||
6908F42B1B500AE500A410E2 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6908F42A1B500AE500A410E2 /* ViewController.swift */; };
|
||||
6908F42E1B500AE500A410E2 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6908F42C1B500AE500A410E2 /* Main.storyboard */; };
|
||||
@@ -16,7 +16,7 @@
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
48A9BFBE20BED26800AC149A /* RAScrollablePickerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RAScrollablePickerView.swift; sourceTree = SOURCE_ROOT; };
|
||||
48D1A6E821160D36007221D1 /* RAScrollablePickerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RAScrollablePickerView.swift; path = Framework/RAScrollablePickerView/RAScrollablePickerView/RAScrollablePickerView.swift; sourceTree = SOURCE_ROOT; };
|
||||
6908F4231B500AE500A410E2 /* ColorPickerExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ColorPickerExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
6908F4271B500AE500A410E2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
6908F4281B500AE500A410E2 /* WindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WindowController.swift; sourceTree = "<group>"; };
|
||||
@@ -57,7 +57,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
6908F42A1B500AE500A410E2 /* ViewController.swift */,
|
||||
48A9BFBE20BED26800AC149A /* RAScrollablePickerView.swift */,
|
||||
48D1A6E821160D36007221D1 /* RAScrollablePickerView.swift */,
|
||||
6908F4261B500AE500A410E2 /* Supporting Files */,
|
||||
);
|
||||
path = ColorPickerExample;
|
||||
@@ -148,7 +148,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
6908F42B1B500AE500A410E2 /* ViewController.swift in Sources */,
|
||||
48A9BFBF20BED26800AC149A /* RAScrollablePickerView.swift in Sources */,
|
||||
48D1A6E921160D36007221D1 /* RAScrollablePickerView.swift in Sources */,
|
||||
6908F4291B500AE500A410E2 /* WindowController.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
||||
BIN
Binary file not shown.
Framework/RAScrollablePickerView/Carthage/Build/iOS/ABB3000F-D09D-3AAC-81C0-1C0AEB4B4447.bcsymbolmap
Generated
Vendored
+275
File diff suppressed because one or more lines are too long
Framework/RAScrollablePickerView/Carthage/Build/iOS/E1A36868-6788-302C-99CF-7AD3859296EF.bcsymbolmap
Generated
Vendored
+276
File diff suppressed because one or more lines are too long
Generated
Vendored
BIN
Binary file not shown.
Generated
Vendored
+11
@@ -163,6 +163,8 @@ typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
|
||||
# define SWIFT_DEPRECATED_OBJC(Msg) SWIFT_DEPRECATED_MSG(Msg)
|
||||
#endif
|
||||
#if __has_feature(modules)
|
||||
@import UIKit;
|
||||
@import CoreGraphics;
|
||||
#endif
|
||||
|
||||
#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
|
||||
@@ -180,6 +182,15 @@ typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
|
||||
# pragma pop_macro("any")
|
||||
#endif
|
||||
|
||||
@class NSCoder;
|
||||
|
||||
SWIFT_CLASS("_TtC22RAScrollablePickerView22RAScrollablePickerView")
|
||||
@interface RAScrollablePickerView : UIView
|
||||
- (nonnull instancetype)initWithFrame:(CGRect)frame OBJC_DESIGNATED_INITIALIZER;
|
||||
- (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)aDecoder OBJC_DESIGNATED_INITIALIZER;
|
||||
- (void)drawRect:(CGRect)rect;
|
||||
@end
|
||||
|
||||
#if __has_attribute(external_source_symbol)
|
||||
# pragma clang attribute pop
|
||||
#endif
|
||||
|
||||
Generated
Vendored
BIN
Binary file not shown.
Generated
Vendored
BIN
Binary file not shown.
Generated
Vendored
BIN
Binary file not shown.
BIN
Binary file not shown.
+26
-22
@@ -17,23 +17,23 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
enum PickerType: Int {
|
||||
public enum PickerType: Int {
|
||||
case hue
|
||||
case saturation
|
||||
case brightness
|
||||
}
|
||||
|
||||
protocol RAScrollablePickerViewDelegate: class {
|
||||
public protocol RAScrollablePickerViewDelegate: class {
|
||||
func valueChanged(_ value: CGFloat, type: PickerType)
|
||||
}
|
||||
|
||||
class RAScrollablePickerView: UIView {
|
||||
public class RAScrollablePickerView: UIView {
|
||||
|
||||
var type: PickerType = .hue
|
||||
var shouldDecelerate = true
|
||||
weak var delegate: RAScrollablePickerViewDelegate?
|
||||
public var type: PickerType = .hue
|
||||
public var shouldDecelerate = true
|
||||
public weak var delegate: RAScrollablePickerViewDelegate?
|
||||
|
||||
var hueValueForPreview: CGFloat = 1.0 {
|
||||
public var hueValueForPreview: CGFloat = 1.0 {
|
||||
didSet {
|
||||
setNeedsDisplay()
|
||||
}
|
||||
@@ -57,31 +57,35 @@ class RAScrollablePickerView: UIView {
|
||||
return UIPanGestureRecognizer(target: self, action: #selector(handlePan(_:)))
|
||||
}()
|
||||
|
||||
private(set) var value: CGFloat = 0.5 {
|
||||
public var value: CGFloat {
|
||||
return pickerValue
|
||||
}
|
||||
|
||||
private var pickerValue: CGFloat = 0.5 {
|
||||
didSet {
|
||||
if type != .hue {
|
||||
if self.value > 1 {
|
||||
self.value = 1
|
||||
if self.pickerValue > 1 {
|
||||
self.pickerValue = 1
|
||||
}
|
||||
else if self.value < 0 {
|
||||
self.value = 0
|
||||
else if self.pickerValue < 0 {
|
||||
self.pickerValue = 0
|
||||
}
|
||||
else {
|
||||
setNeedsDisplay()
|
||||
}
|
||||
}
|
||||
else {
|
||||
if self.value > 1 {
|
||||
self.value -= 1
|
||||
if self.pickerValue > 1 {
|
||||
self.pickerValue -= 1
|
||||
}
|
||||
else if self.value < 0 {
|
||||
self.value += 1
|
||||
else if self.pickerValue < 0 {
|
||||
self.pickerValue += 1
|
||||
}
|
||||
else {
|
||||
setNeedsDisplay()
|
||||
}
|
||||
}
|
||||
delegate?.valueChanged(self.value, type: type)
|
||||
delegate?.valueChanged(pickerValue, type: type)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +147,7 @@ class RAScrollablePickerView: UIView {
|
||||
}
|
||||
else if gesture.state == .changed {
|
||||
if let location = lastTouchLocation {
|
||||
value += (gesture.location(in: self).x - location.x) / frame.width
|
||||
pickerValue += (gesture.location(in: self).x - location.x) / frame.width
|
||||
}
|
||||
lastTouchLocation = gesture.location(in: self)
|
||||
}
|
||||
@@ -162,7 +166,7 @@ class RAScrollablePickerView: UIView {
|
||||
return
|
||||
}
|
||||
|
||||
value += (decelerationSpeed * 0.025) / 100
|
||||
pickerValue += (decelerationSpeed * 0.025) / 100
|
||||
}
|
||||
|
||||
private func commonInit() {
|
||||
@@ -171,17 +175,17 @@ class RAScrollablePickerView: UIView {
|
||||
clipsToBounds = true
|
||||
}
|
||||
|
||||
override init(frame: CGRect) {
|
||||
public override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
commonInit()
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
public required init?(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
commonInit()
|
||||
}
|
||||
|
||||
override func draw(_ rect: CGRect) {
|
||||
public override func draw(_ rect: CGRect) {
|
||||
let ctx = UIGraphicsGetCurrentContext()
|
||||
|
||||
if let gradient = CGGradient(colorsSpace: CGColorSpaceCreateDeviceRGB(), colors: colors(for: value) as CFArray, locations: [0, 0.25, 0.5, 0.75, 1]) {
|
||||
|
||||
Reference in New Issue
Block a user