diff --git a/Example/rubber-range-picker.xcodeproj/project.pbxproj b/Example/rubber-range-picker.xcodeproj/project.pbxproj index 5f19a30..a4b1374 100644 --- a/Example/rubber-range-picker.xcodeproj/project.pbxproj +++ b/Example/rubber-range-picker.xcodeproj/project.pbxproj @@ -10,8 +10,8 @@ 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; }; 607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; }; 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; }; - 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; }; - 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; }; + CE503451221B0EBC007A556B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CE50344F221B0EBC007A556B /* LaunchScreen.storyboard */; }; + CEF8B755221B109F0000A3E2 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CEF8B754221B109F0000A3E2 /* Images.xcassets */; }; D68331A069F265D437D923C7 /* Pods_rubber_range_picker_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CBD78FB19F5524DBA3E861E4 /* Pods_rubber_range_picker_Example.framework */; }; /* End PBXBuildFile section */ @@ -23,13 +23,13 @@ 607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 607FACD71AFB9204008FA782 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 607FACDA1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; - 607FACDC1AFB9204008FA782 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; - 607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 6950D51C745AA570E97D8B51 /* Pods-rubber-range-picker_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-rubber-range-picker_Example.debug.xcconfig"; path = "Target Support Files/Pods-rubber-range-picker_Example/Pods-rubber-range-picker_Example.debug.xcconfig"; sourceTree = ""; }; 80F4B68D2372213B9E6A1537 /* Pods_rubber_range_picker_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_rubber_range_picker_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 86283CD14BECA0BA17C7955E /* Pods-rubber-range-picker_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-rubber-range-picker_Tests.debug.xcconfig"; path = "Target Support Files/Pods-rubber-range-picker_Tests/Pods-rubber-range-picker_Tests.debug.xcconfig"; sourceTree = ""; }; CB4FC64D813F0522779A2DB9 /* Pods-rubber-range-picker_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-rubber-range-picker_Tests.release.xcconfig"; path = "Target Support Files/Pods-rubber-range-picker_Tests/Pods-rubber-range-picker_Tests.release.xcconfig"; sourceTree = ""; }; CBD78FB19F5524DBA3E861E4 /* Pods_rubber_range_picker_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_rubber_range_picker_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + CE503450221B0EBC007A556B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + CEF8B754221B109F0000A3E2 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; EC14AE661B72A2C3A43980F0 /* Pods-rubber-range-picker_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-rubber-range-picker_Example.release.xcconfig"; path = "Target Support Files/Pods-rubber-range-picker_Example/Pods-rubber-range-picker_Example.release.xcconfig"; sourceTree = ""; }; F04E529041432A7AECAFAB79 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; /* End PBXFileReference section */ @@ -79,11 +79,11 @@ 607FACD21AFB9204008FA782 /* Example for rubber-range-picker */ = { isa = PBXGroup; children = ( + CEF8B754221B109F0000A3E2 /* Images.xcassets */, + CE50344F221B0EBC007A556B /* LaunchScreen.storyboard */, 607FACD51AFB9204008FA782 /* AppDelegate.swift */, 607FACD71AFB9204008FA782 /* ViewController.swift */, 607FACD91AFB9204008FA782 /* Main.storyboard */, - 607FACDC1AFB9204008FA782 /* Images.xcassets */, - 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */, 607FACD31AFB9204008FA782 /* Supporting Files */, ); name = "Example for rubber-range-picker"; @@ -179,9 +179,9 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + CEF8B755221B109F0000A3E2 /* Images.xcassets in Resources */, + CE503451221B0EBC007A556B /* LaunchScreen.storyboard in Resources */, 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */, - 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */, - 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -255,12 +255,12 @@ name = Main.storyboard; sourceTree = ""; }; - 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */ = { + CE50344F221B0EBC007A556B /* LaunchScreen.storyboard */ = { isa = PBXVariantGroup; children = ( - 607FACDF1AFB9204008FA782 /* Base */, + CE503450221B0EBC007A556B /* Base */, ); - name = LaunchScreen.xib; + name = LaunchScreen.storyboard; sourceTree = ""; }; /* End PBXVariantGroup section */ diff --git a/Example/rubber-range-picker/Base.lproj/LaunchScreen.storyboard b/Example/rubber-range-picker/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..24acd6f --- /dev/null +++ b/Example/rubber-range-picker/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/rubber-range-picker/Base.lproj/LaunchScreen.xib b/Example/rubber-range-picker/Base.lproj/LaunchScreen.xib deleted file mode 100644 index 474efec..0000000 --- a/Example/rubber-range-picker/Base.lproj/LaunchScreen.xib +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Example/rubber-range-picker/Base.lproj/Main.storyboard b/Example/rubber-range-picker/Base.lproj/Main.storyboard index a97fac5..f246b79 100644 --- a/Example/rubber-range-picker/Base.lproj/Main.storyboard +++ b/Example/rubber-range-picker/Base.lproj/Main.storyboard @@ -13,7 +13,7 @@ - + diff --git a/Example/rubber-range-picker/Images.xcassets/AppIcon.appiconset/Contents.json b/Example/rubber-range-picker/Images.xcassets/AppIcon.appiconset/Contents.json index 7006c9e..c7f26a4 100644 --- a/Example/rubber-range-picker/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/Example/rubber-range-picker/Images.xcassets/AppIcon.appiconset/Contents.json @@ -31,13 +31,15 @@ "scale" : "3x" }, { - "idiom" : "iphone", "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon_60@2x.png", "scale" : "2x" }, { - "idiom" : "iphone", "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon_60@3x.png", "scale" : "3x" }, { @@ -50,4 +52,4 @@ "version" : 1, "author" : "xcode" } -} +} \ No newline at end of file diff --git a/Example/rubber-range-picker/Images.xcassets/AppIcon.appiconset/Icon_60@2x.png b/Example/rubber-range-picker/Images.xcassets/AppIcon.appiconset/Icon_60@2x.png new file mode 100644 index 0000000..08b120f Binary files /dev/null and b/Example/rubber-range-picker/Images.xcassets/AppIcon.appiconset/Icon_60@2x.png differ diff --git a/Example/rubber-range-picker/Images.xcassets/AppIcon.appiconset/Icon_60@3x.png b/Example/rubber-range-picker/Images.xcassets/AppIcon.appiconset/Icon_60@3x.png new file mode 100644 index 0000000..0fd4ca2 Binary files /dev/null and b/Example/rubber-range-picker/Images.xcassets/AppIcon.appiconset/Icon_60@3x.png differ diff --git a/Example/rubber-range-picker/Images.xcassets/Contents.json b/Example/rubber-range-picker/Images.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/Example/rubber-range-picker/Images.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example/rubber-range-picker/Images.xcassets/cuberto-logo.imageset/Contents.json b/Example/rubber-range-picker/Images.xcassets/cuberto-logo.imageset/Contents.json new file mode 100644 index 0000000..cf0fd58 --- /dev/null +++ b/Example/rubber-range-picker/Images.xcassets/cuberto-logo.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "cuberto-logo.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "cuberto-logo@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "cuberto-logo@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example/rubber-range-picker/Images.xcassets/cuberto-logo.imageset/cuberto-logo.png b/Example/rubber-range-picker/Images.xcassets/cuberto-logo.imageset/cuberto-logo.png new file mode 100644 index 0000000..dd33fa3 Binary files /dev/null and b/Example/rubber-range-picker/Images.xcassets/cuberto-logo.imageset/cuberto-logo.png differ diff --git a/Example/rubber-range-picker/Images.xcassets/cuberto-logo.imageset/cuberto-logo@2x.png b/Example/rubber-range-picker/Images.xcassets/cuberto-logo.imageset/cuberto-logo@2x.png new file mode 100644 index 0000000..c0d96dd Binary files /dev/null and b/Example/rubber-range-picker/Images.xcassets/cuberto-logo.imageset/cuberto-logo@2x.png differ diff --git a/Example/rubber-range-picker/Images.xcassets/cuberto-logo.imageset/cuberto-logo@3x.png b/Example/rubber-range-picker/Images.xcassets/cuberto-logo.imageset/cuberto-logo@3x.png new file mode 100644 index 0000000..785b76a Binary files /dev/null and b/Example/rubber-range-picker/Images.xcassets/cuberto-logo.imageset/cuberto-logo@3x.png differ diff --git a/Example/rubber-range-picker/en.lproj/LaunchScreen.strings b/Example/rubber-range-picker/en.lproj/LaunchScreen.strings new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Example/rubber-range-picker/en.lproj/LaunchScreen.strings @@ -0,0 +1 @@ + diff --git a/README.md b/README.md index 2122128..5ce082f 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Cuberto is a leading digital agency with solid design and development expertise. [![CocoaPods](https://img.shields.io/cocoapods/v/rubber-range-picker.svg?style=flat)](http://cocoapods.org/pods/rubber-range-picker) [![Swift 4.2](https://img.shields.io/badge/Swift-4.2-green.svg?style=flat)](https://developer.apple.com/swift/) - +![Animation](https://raw.githubusercontent.com/Cuberto/rubber-range-picker/master/Screenshots/animation.gif) ## Example diff --git a/Screenshots/animation.gif b/Screenshots/animation.gif new file mode 100644 index 0000000..192fe38 Binary files /dev/null and b/Screenshots/animation.gif differ diff --git a/rubber-range-picker/Classes/RubberRangePicker.swift b/rubber-range-picker/Classes/RubberRangePicker.swift index 0a278fb..6fb8d14 100644 --- a/rubber-range-picker/Classes/RubberRangePicker.swift +++ b/rubber-range-picker/Classes/RubberRangePicker.swift @@ -96,6 +96,8 @@ import UIKit } } + @IBInspectable open var enableValueStep: Bool = false + @IBInspectable open var stepValue: Double = 1.0 private var trackLayer = RubberTrackLayer() private var lowerThumb = RubberRangeThumb() @@ -172,9 +174,15 @@ import UIKit if movingLower { lowerValue = bound(value: lowerValue + deltaValue, toLowerValue: minimumValue, upperValue: maximumValue) upperValue = max(upperValue, lowerValue) + if enableValueStep == true { + lowerValue = Double(roundf(Float(lowerValue / stepValue))) * stepValue + } } else if movingUpper { upperValue = bound(value: upperValue + deltaValue, toLowerValue: minimumValue, upperValue: maximumValue) lowerValue = min(upperValue, lowerValue) + if enableValueStep == true { + upperValue = Double(roundf(Float(upperValue / stepValue))) * stepValue + } } let touchOffset = (location.y - bounds.height/2.0)