diff --git a/Pods/Pods.xcodeproj/project.pbxproj b/Pods/Pods.xcodeproj/project.pbxproj index bb60ed2..88223c8 100644 --- a/Pods/Pods.xcodeproj/project.pbxproj +++ b/Pods/Pods.xcodeproj/project.pbxproj @@ -138,7 +138,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0700; + LastUpgradeCheck = 1010; TargetAttributes = { 03FB074AEADEC0BEC1BBD499D509E050 = { LastSwiftMigration = 0800; @@ -183,18 +183,30 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = YES; ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "POD_CONFIGURATION_RELEASE=1", "$(inherited)", @@ -221,19 +233,31 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "POD_CONFIGURATION_DEBUG=1", @@ -258,6 +282,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 666A7525A67E58FA89CFEF4D70F842A8 /* Pods-SwiftRangeSlider.release.xcconfig */; buildSettings = { + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -292,6 +317,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 9F9215C9B9EF616BB7EF613AD437F751 /* Pods-SwiftRangeSlider.debug.xcconfig */; buildSettings = { + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = dwarf; diff --git a/SwiftRangeSlider.xcodeproj/project.pbxproj b/SwiftRangeSlider.xcodeproj/project.pbxproj index 87f0055..47f8182 100644 --- a/SwiftRangeSlider.xcodeproj/project.pbxproj +++ b/SwiftRangeSlider.xcodeproj/project.pbxproj @@ -18,7 +18,7 @@ 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 = ""; }; + E806712D1CF27E3F00EAE8FA /* RangeSlider.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.swift; path = RangeSlider.swift; sourceTree = ""; tabWidth = 2; }; E806712E1CF27E3F00EAE8FA /* RangeSliderKnob.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RangeSliderKnob.swift; sourceTree = ""; }; E806712F1CF27E3F00EAE8FA /* RangeSliderTrack.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RangeSliderTrack.swift; sourceTree = ""; }; F4C9601CE5B09153BABEA21E /* Pods-SwiftRangeSlider.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftRangeSlider.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SwiftRangeSlider/Pods-SwiftRangeSlider.debug.xcconfig"; sourceTree = ""; }; @@ -123,13 +123,13 @@ E80671191CF27AFB00EAE8FA /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0800; + LastUpgradeCheck = 1010; ORGANIZATIONNAME = "Caramel Apps"; TargetAttributes = { E80671211CF27AFB00EAE8FA = { CreatedOnToolsVersion = 7.3.1; DevelopmentTeam = YFLQ5CNLWN; - LastSwiftMigration = 0800; + LastSwiftMigration = 1010; }; }; }; @@ -216,14 +216,22 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 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_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -267,14 +275,22 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 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_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -320,7 +336,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -340,7 +356,7 @@ PRODUCT_BUNDLE_IDENTIFIER = CA.SwiftRangeSlider; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/SwiftRangeSlider.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/SwiftRangeSlider.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/SwiftRangeSlider.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/SwiftRangeSlider.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/SwiftRangeSlider.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/SwiftRangeSlider.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/SwiftRangeSlider/RangeSlider.swift b/SwiftRangeSlider/RangeSlider.swift index d47f1df..1d32780 100644 --- a/SwiftRangeSlider/RangeSlider.swift +++ b/SwiftRangeSlider/RangeSlider.swift @@ -176,6 +176,11 @@ import QuartzCore } } + /** + * Adittional draggable area around knob (optional, default is 0.0). + */ + open var knobDraggableArea : KnobInset = KnobInset(dx: 0, dy: 0) + var previousLocation = CGPoint() var previouslySelectedKnob = Knob.Neither @@ -257,7 +262,7 @@ import QuartzCore upperKnob.contentsScale = UIScreen.main.scale layer.addSublayer(upperKnob) - lowerLabel.alignmentMode = kCAAlignmentCenter + lowerLabel.alignmentMode = CATextLayerAlignmentMode.center lowerLabel.fontSize = labelFontSize lowerLabel.frame = CGRect(x: 0, y: 0, width: 75, height: labelFontSize) lowerLabel.contentsScale = UIScreen.main.scale @@ -265,7 +270,7 @@ import QuartzCore lowerLabel.foregroundColor = labelColor.cgColor layer.addSublayer(lowerLabel) - upperLabel.alignmentMode = kCAAlignmentCenter + upperLabel.alignmentMode = CATextLayerAlignmentMode.center upperLabel.fontSize = labelFontSize upperLabel.frame = CGRect(x: 0, y: 0, width: 75, height: labelFontSize) upperLabel.contentsScale = UIScreen.main.scale @@ -340,8 +345,8 @@ import QuartzCore lowerLabel.foregroundColor = labelColor.cgColor upperLabel.foregroundColor = labelColor.cgColor - lowerLabelTextSize = (lowerLabel.string as! NSString).size(attributes: [NSFontAttributeName : UIFont.systemFont(ofSize: labelFontSize)]) - upperLabelTextSize = (upperLabel.string as! NSString).size(attributes: [NSFontAttributeName : UIFont.systemFont(ofSize: labelFontSize)]) + lowerLabelTextSize = (lowerLabel.string as! NSString).size(withAttributes: [NSAttributedString.Key.font : UIFont.systemFont(ofSize: labelFontSize)]) + upperLabelTextSize = (upperLabel.string as! NSString).size(withAttributes: [NSAttributedString.Key.font : UIFont.systemFont(ofSize: labelFontSize)]) } ///Updates the labels positions above the knobs. @@ -385,11 +390,22 @@ import QuartzCore - returns: A bool indicating if either of the slider buttons were inside of the `UITouch`. */ override open func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { + previousLocation = touch.location(in: self) - if lowerKnob.frame.contains(previousLocation) && upperKnob.frame.contains(previousLocation) { + let lowerKnobDraggableArea = lowerKnob.frame.insetBy( + dx: -abs(knobDraggableArea.dx), + dy: -abs(knobDraggableArea.dy) + ) + + let upperKnobDraggableArea = upperKnob.frame.insetBy( + dx: -abs(knobDraggableArea.dx), + dy: -abs(knobDraggableArea.dy) + ) + + if lowerKnobDraggableArea.contains(previousLocation) && upperKnobDraggableArea.contains(previousLocation) { - if knobsAreClose { + if knobsAreClose { let knobToHighlight = knobsAreCloserToMinimum ? upperKnob : lowerKnob let knobPosiition = knobsAreCloserToMinimum ? Knob.Upper : Knob.Lower highlightKnob(knobToHighlight, knobPosition: knobPosiition) @@ -402,12 +418,12 @@ import QuartzCore return true } - if lowerKnob.frame.contains(previousLocation) { + if lowerKnobDraggableArea.contains(previousLocation) { highlightKnob(lowerKnob, knobPosition: Knob.Lower) return true } - if upperKnob.frame.contains(previousLocation) { + if upperKnobDraggableArea.contains(previousLocation) { highlightKnob(upperKnob, knobPosition: Knob.Upper) return true } @@ -492,7 +508,7 @@ import QuartzCore func animateKnob(knob: RangeSliderKnob, selected:Bool) { CATransaction.begin() CATransaction.setAnimationDuration(0.3) - CATransaction.setAnimationTimingFunction(CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn)) + CATransaction.setAnimationTimingFunction(CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeIn)) knob.transform = selected ? CATransform3DMakeScale(selectedKnobDiameterMultiplier, selectedKnobDiameterMultiplier, 1) : CATransform3DIdentity diff --git a/SwiftRangeSlider/RangeSliderKnob.swift b/SwiftRangeSlider/RangeSliderKnob.swift index 38be022..3f48867 100644 --- a/SwiftRangeSlider/RangeSliderKnob.swift +++ b/SwiftRangeSlider/RangeSliderKnob.swift @@ -62,3 +62,15 @@ class RangeSliderKnob: CALayer { } } } + +// MARK: - Knob frame inset +public struct KnobInset { + let dx: CGFloat + let dy: CGFloat + public init(dx: CGFloat, dy: CGFloat) { + self.dx = dx + self.dy = dy + } +} + +