diff --git a/Pods/Pods.xcodeproj/project.pbxproj b/Pods/Pods.xcodeproj/project.pbxproj
index 4ebfacd..bb60ed2 100644
--- a/Pods/Pods.xcodeproj/project.pbxproj
+++ b/Pods/Pods.xcodeproj/project.pbxproj
@@ -139,6 +139,11 @@
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0700;
+ TargetAttributes = {
+ 03FB074AEADEC0BEC1BBD499D509E050 = {
+ LastSwiftMigration = 0800;
+ };
+ };
};
buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */;
compatibilityVersion = "Xcode 3.2";
@@ -276,6 +281,7 @@
PRODUCT_NAME = Pods_SwiftRangeSlider;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
+ SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
@@ -309,6 +315,7 @@
PRODUCT_NAME = Pods_SwiftRangeSlider;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
+ SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
diff --git a/SwiftRangeSlider copy-Info.plist b/SwiftRangeSlider copy-Info.plist
new file mode 100644
index 0000000..d3de8ee
--- /dev/null
+++ b/SwiftRangeSlider copy-Info.plist
@@ -0,0 +1,26 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ en
+ CFBundleExecutable
+ $(EXECUTABLE_NAME)
+ CFBundleIdentifier
+ $(PRODUCT_BUNDLE_IDENTIFIER)
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ $(PRODUCT_NAME)
+ CFBundlePackageType
+ FMWK
+ CFBundleShortVersionString
+ 1.0
+ CFBundleSignature
+ ????
+ CFBundleVersion
+ $(CURRENT_PROJECT_VERSION)
+ NSPrincipalClass
+
+
+
diff --git a/SwiftRangeSlider.xcodeproj/project.pbxproj b/SwiftRangeSlider.xcodeproj/project.pbxproj
index ff4a9cc..61bae11 100644
--- a/SwiftRangeSlider.xcodeproj/project.pbxproj
+++ b/SwiftRangeSlider.xcodeproj/project.pbxproj
@@ -15,6 +15,7 @@
/* Begin PBXFileReference section */
13BCA713F988FE09DF748C40 /* Pods_SwiftRangeSlider.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftRangeSlider.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+ 5B00DA9C1D9A5FE900A0A8D7 /* SwiftRangeSlider copy-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "SwiftRangeSlider copy-Info.plist"; path = "/Users/gmabber/Dropbox/code/iphone/SwiftRangeSlider/SwiftRangeSlider copy-Info.plist"; sourceTree = ""; };
E80671221CF27AFB00EAE8FA /* SwiftRangeSlider.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftRangeSlider.framework; sourceTree = BUILT_PRODUCTS_DIR; };
E80671271CF27AFB00EAE8FA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
E806712D1CF27E3F00EAE8FA /* RangeSlider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RangeSlider.swift; sourceTree = ""; };
@@ -60,6 +61,7 @@
E80671231CF27AFB00EAE8FA /* Products */,
6093D5A44E5D451567813780 /* Pods */,
1B58CD645E8610742E795183 /* Frameworks */,
+ 5B00DA9C1D9A5FE900A0A8D7 /* SwiftRangeSlider copy-Info.plist */,
);
sourceTree = "";
};
@@ -121,12 +123,13 @@
E80671191CF27AFB00EAE8FA /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 0730;
+ LastUpgradeCheck = 0800;
ORGANIZATIONNAME = "Caramel Apps";
TargetAttributes = {
E80671211CF27AFB00EAE8FA = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = YFLQ5CNLWN;
+ LastSwiftMigration = 0800;
};
};
};
@@ -218,8 +221,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -267,8 +272,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -288,6 +295,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
+ SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
@@ -300,6 +308,7 @@
baseConfigurationReference = F4C9601CE5B09153BABEA21E /* Pods-SwiftRangeSlider.debug.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
@@ -311,6 +320,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ SWIFT_VERSION = 3.0;
};
name = Debug;
};
@@ -319,6 +329,7 @@
baseConfigurationReference = F945C7875809BC1BDCB729D1 /* Pods-SwiftRangeSlider.release.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
@@ -329,6 +340,7 @@
PRODUCT_BUNDLE_IDENTIFIER = CA.SwiftRangeSlider;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
+ SWIFT_VERSION = 3.0;
};
name = Release;
};
diff --git a/SwiftRangeSlider/RangeSlider.swift b/SwiftRangeSlider/RangeSlider.swift
index ae916f4..ee61ea5 100644
--- a/SwiftRangeSlider/RangeSlider.swift
+++ b/SwiftRangeSlider/RangeSlider.swift
@@ -11,60 +11,60 @@ import QuartzCore
///Class that represents the RangeSlider object.
-@IBDesignable public class RangeSlider: UIControl {
+@IBDesignable open class RangeSlider: UIControl {
// MARK: - Properties
///The minimum value selectable on the RangeSlider
- @IBInspectable public var minimumValue: Double = 0.0 {
+ @IBInspectable open var minimumValue: Double = 0.0 {
didSet {
updateLayerFrames()
}
}
///The maximum value selectable on the RangeSlider
- @IBInspectable public var maximumValue: Double = 1.0 {
+ @IBInspectable open var maximumValue: Double = 1.0 {
didSet {
updateLayerFrames()
}
}
///The current lower value selected on the RangeSlider
- @IBInspectable public var lowerValue: Double = 0.2 {
+ @IBInspectable open var lowerValue: Double = 0.2 {
didSet {
updateLayerFrames()
}
}
///The current upper value selected on the RangeSlider
- @IBInspectable public var upperValue: Double = 0.8 {
+ @IBInspectable open var upperValue: Double = 0.8 {
didSet {
updateLayerFrames()
}
}
///The color of the track bar outside of the selected range
- @IBInspectable public var trackTintColor: UIColor = UIColor(white: 0.9, alpha: 1.0) {
+ @IBInspectable open var trackTintColor: UIColor = UIColor(white: 0.9, alpha: 1.0) {
didSet {
trackLayer.setNeedsDisplay()
}
}
///The color of the track bar within the selected range
- @IBInspectable public var trackHighlightTintColor: UIColor = UIColor(red: 0.0, green: 0.45, blue: 0.94, alpha: 1.0) {
+ @IBInspectable open var trackHighlightTintColor: UIColor = UIColor(red: 0.0, green: 0.45, blue: 0.94, alpha: 1.0) {
didSet {
trackLayer.setNeedsDisplay()
}
}
///the thickness of the track bar. `0.1` by default.
- @IBInspectable public var trackThickness: CGFloat = 0.1 {
+ @IBInspectable open var trackThickness: CGFloat = 0.1 {
didSet {
updateLayerFrames()
}
}
///The color of the slider buttons. `White` by default.
- @IBInspectable public var thumbTintColor: UIColor = UIColor.whiteColor() {
+ @IBInspectable open var thumbTintColor: UIColor = UIColor.white {
didSet {
lowerThumbLayer.setNeedsDisplay()
upperThumbLayer.setNeedsDisplay()
@@ -72,7 +72,7 @@ import QuartzCore
}
///The thickness of the slider buttons border. `0.1` by default.
- @IBInspectable public var thumbBorderThickness: CGFloat = 0.1 {
+ @IBInspectable open var thumbBorderThickness: CGFloat = 0.1 {
didSet {
lowerThumbLayer.setNeedsDisplay()
upperThumbLayer.setNeedsDisplay()
@@ -80,7 +80,7 @@ import QuartzCore
}
///Whether or not the slider buttons have a shadow. `true` by default.
- @IBInspectable public var thumbHasShadow: Bool = true {
+ @IBInspectable open var thumbHasShadow: Bool = true {
didSet{
lowerThumbLayer.setNeedsDisplay()
upperThumbLayer.setNeedsDisplay()
@@ -88,7 +88,7 @@ import QuartzCore
}
///The curvaceousness of the ends of the track bar and the slider buttons. `1.0` by default.
- @IBInspectable public var curvaceousness: CGFloat = 1.0 {
+ @IBInspectable open var curvaceousness: CGFloat = 1.0 {
didSet {
trackLayer.setNeedsDisplay()
lowerThumbLayer.setNeedsDisplay()
@@ -107,7 +107,7 @@ import QuartzCore
}
///The frame of the `RangeSlider` instance.
- override public var frame: CGRect {
+ override open var frame: CGRect {
didSet {
updateLayerFrames()
}
@@ -137,15 +137,15 @@ import QuartzCore
func addContentViews(){
trackLayer.rangeSlider = self
- trackLayer.contentsScale = UIScreen.mainScreen().scale
+ trackLayer.contentsScale = UIScreen.main.scale
layer.addSublayer(trackLayer)
lowerThumbLayer.rangeSlider = self
- lowerThumbLayer.contentsScale = UIScreen.mainScreen().scale
+ lowerThumbLayer.contentsScale = UIScreen.main.scale
layer.addSublayer(lowerThumbLayer)
upperThumbLayer.rangeSlider = self
- upperThumbLayer.contentsScale = UIScreen.mainScreen().scale
+ upperThumbLayer.contentsScale = UIScreen.main.scale
layer.addSublayer(upperThumbLayer)
}
@@ -153,7 +153,7 @@ import QuartzCore
///Updates all of the layer frames that make up the `RangeSlider` instance.
- public func updateLayerFrames() {
+ open func updateLayerFrames() {
CATransaction.begin()
CATransaction.setDisableActions(true)
let newTrackDy = (frame.height - frame.height * trackThickness) / 2
@@ -173,12 +173,12 @@ import QuartzCore
CATransaction.commit()
}
- func positionForValue(value: Double) -> Double {
+ func positionForValue(_ value: Double) -> Double {
return Double(bounds.width - thumbWidth) * (value - minimumValue) /
(maximumValue - minimumValue) + Double(thumbWidth / 2.0)
}
- func boundValue(value: Double, toLowerValue lowerValue: Double, upperValue: Double) -> Double {
+ func boundValue(_ value: Double, toLowerValue lowerValue: Double, upperValue: Double) -> Double {
return min(max(value, lowerValue), upperValue)
}
@@ -187,8 +187,8 @@ import QuartzCore
- returns: A bool indicating if either of the slider buttons were inside of the `UITouch`.
*/
- override public func beginTrackingWithTouch(touch: UITouch, withEvent event: UIEvent?) -> Bool {
- previousLocation = touch.locationInView(self)
+ override open func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
+ previousLocation = touch.location(in: self)
if lowerThumbLayer.frame.contains(previousLocation) {
lowerThumbLayer.highlighted = true
@@ -205,8 +205,8 @@ import QuartzCore
- returns: A bool indicating success.
*/
- override public func continueTrackingWithTouch(touch: UITouch, withEvent event: UIEvent?) -> Bool {
- let location = touch.locationInView(self)
+ override open func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
+ let location = touch.location(in: self)
let deltaLocation = Double(location.x - previousLocation.x)
let deltaValue = (maximumValue - minimumValue) * deltaLocation / Double(bounds.width - thumbWidth)
@@ -221,7 +221,7 @@ import QuartzCore
upperValue = boundValue(upperValue, toLowerValue: lowerValue, upperValue: maximumValue)
}
- sendActionsForControlEvents(.ValueChanged)
+ sendActions(for: .valueChanged)
return true
}
@@ -229,7 +229,7 @@ import QuartzCore
/**
Triggers on the end of touch of the `RangeSlider` and sets the button layers `highlighted` property to `false`.
*/
- override public func endTrackingWithTouch(touch: UITouch?, withEvent event: UIEvent?) {
+ override open func endTracking(_ touch: UITouch?, with event: UIEvent?) {
lowerThumbLayer.highlighted = false
upperThumbLayer.highlighted = false
}
diff --git a/SwiftRangeSlider/RangeSliderThumbLayer.swift b/SwiftRangeSlider/RangeSliderThumbLayer.swift
index b5ab5a0..143be55 100644
--- a/SwiftRangeSlider/RangeSliderThumbLayer.swift
+++ b/SwiftRangeSlider/RangeSliderThumbLayer.swift
@@ -17,29 +17,29 @@ class RangeSliderThumbLayer: CALayer {
}
weak var rangeSlider: RangeSlider?
- override func drawInContext(ctx: CGContext) {
+ override func draw(in ctx: CGContext) {
if let slider = rangeSlider {
let thumbFrame = bounds.insetBy(dx: 2.0, dy: 2.0)
let cornerRadius = thumbFrame.height * slider.curvaceousness / 2
let thumbPath = UIBezierPath(roundedRect: thumbFrame, cornerRadius: cornerRadius)
- let shadowColor = UIColor.grayColor()
+ let shadowColor = UIColor.gray
if (rangeSlider!.thumbHasShadow){
- CGContextSetShadowWithColor(ctx, CGSize(width: 0.0, height: 1.0), 1.0, shadowColor.CGColor)
+ ctx.setShadow(offset: CGSize(width: 0.0, height: 1.0), blur: 1.0, color: shadowColor.cgColor)
}
- CGContextSetFillColorWithColor(ctx, slider.thumbTintColor.CGColor)
- CGContextAddPath(ctx, thumbPath.CGPath)
- CGContextFillPath(ctx)
+ ctx.setFillColor(slider.thumbTintColor.cgColor)
+ ctx.addPath(thumbPath.cgPath)
+ ctx.fillPath()
- CGContextSetStrokeColorWithColor(ctx, shadowColor.CGColor)
- CGContextSetLineWidth(ctx, (rangeSlider?.thumbBorderThickness)!)
- CGContextAddPath(ctx, thumbPath.CGPath)
- CGContextStrokePath(ctx)
+ ctx.setStrokeColor(shadowColor.cgColor)
+ ctx.setLineWidth((rangeSlider?.thumbBorderThickness)!)
+ ctx.addPath(thumbPath.cgPath)
+ ctx.strokePath()
if highlighted {
- CGContextSetFillColorWithColor(ctx, UIColor(white: 0.0, alpha: 0.1).CGColor)
- CGContextAddPath(ctx, thumbPath.CGPath)
- CGContextFillPath(ctx)
+ ctx.setFillColor(UIColor(white: 0.0, alpha: 0.1).cgColor)
+ ctx.addPath(thumbPath.cgPath)
+ ctx.fillPath()
}
}
}
diff --git a/SwiftRangeSlider/RangeSliderTrackLayer.swift b/SwiftRangeSlider/RangeSliderTrackLayer.swift
index 4f2169f..1f92523 100644
--- a/SwiftRangeSlider/RangeSliderTrackLayer.swift
+++ b/SwiftRangeSlider/RangeSliderTrackLayer.swift
@@ -12,24 +12,24 @@ import QuartzCore
class RangeSliderTrackLayer: CALayer {
weak var rangeSlider: RangeSlider?
- override func drawInContext(ctx: CGContext) {
+ override func draw(in ctx: CGContext) {
if let slider = rangeSlider {
// Clip
let cornerRadius = bounds.height * slider.curvaceousness / 2.0
let path = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius)
- CGContextAddPath(ctx, path.CGPath)
+ ctx.addPath(path.cgPath)
// Fill the track
- CGContextSetFillColorWithColor(ctx, slider.trackTintColor.CGColor)
- CGContextAddPath(ctx, path.CGPath)
- CGContextFillPath(ctx)
+ ctx.setFillColor(slider.trackTintColor.cgColor)
+ ctx.addPath(path.cgPath)
+ ctx.fillPath()
// Fill the highlighted range
- CGContextSetFillColorWithColor(ctx, slider.trackHighlightTintColor.CGColor)
+ ctx.setFillColor(slider.trackHighlightTintColor.cgColor)
let lowerValuePosition = CGFloat(slider.positionForValue(slider.lowerValue))
let upperValuePosition = CGFloat(slider.positionForValue(slider.upperValue))
let rect = CGRect(x: lowerValuePosition, y: 0.0, width: upperValuePosition - lowerValuePosition, height: bounds.height)
- CGContextFillRect(ctx, rect)
+ ctx.fill(rect)
}
}
}