├── .gitignore ├── .swift-version ├── Class └── PFStepper.swift ├── LICENSE ├── PFStepper.podspec ├── PFStepperDemo ├── PFStepperDemo.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── PFStepperDemo │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ └── ViewController.swift ├── README.md └── Sample.gif /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/swift 3 | 4 | ### Swift ### 5 | # Xcode 6 | # 7 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 8 | 9 | ## Build generated 10 | build/ 11 | DerivedData 12 | 13 | ## Various settings 14 | *.pbxuser 15 | !default.pbxuser 16 | *.mode1v3 17 | !default.mode1v3 18 | *.mode2v3 19 | !default.mode2v3 20 | *.perspectivev3 21 | !default.perspectivev3 22 | xcuserdata 23 | 24 | ## Other 25 | *.xccheckout 26 | *.moved-aside 27 | *.xcuserstate 28 | *.xcscmblueprint 29 | 30 | ## Obj-C/Swift specific 31 | *.hmap 32 | *.ipa 33 | 34 | # Swift Package Manager 35 | # 36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 37 | # Packages/ 38 | .build/ 39 | 40 | # CocoaPods 41 | # 42 | # We recommend against adding the Pods directory to your .gitignore. However 43 | # you should judge for yourself, the pros and cons are mentioned at: 44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 45 | # 46 | # Pods/ 47 | 48 | # Carthage 49 | # 50 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 51 | # Carthage/Checkouts 52 | 53 | Carthage/Build 54 | 55 | # fastlane 56 | # 57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 58 | # screenshots whenever they are needed. 59 | # For more information about the recommended setup visit: 60 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md 61 | 62 | fastlane/report.xml 63 | fastlane/screenshots 64 | 65 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 3.0 2 | -------------------------------------------------------------------------------- /Class/PFStepper.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PFStepper.swift 3 | // PFStepper 4 | // 5 | // Created by Cee on 22/12/2015. 6 | // Copyright © 2015 Cee. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | open class PFStepper: UIControl { 12 | open var value: Double = 0 { 13 | didSet { 14 | value = min(maximumValue, max(minimumValue, value)) 15 | 16 | let isInteger = floor(value) == value 17 | 18 | if showIntegerIfDoubleIsInteger && isInteger { 19 | topButton.setTitle(String(stringInterpolationSegment: Int(value)), for: UIControlState()) 20 | bottomButton.setTitle(String(stringInterpolationSegment: Int(value + stepValue)), for: UIControlState()) 21 | } else { 22 | topButton.setTitle(String(stringInterpolationSegment: value), for: UIControlState()) 23 | bottomButton.setTitle(String(stringInterpolationSegment: value + stepValue), for: UIControlState()) 24 | } 25 | 26 | if oldValue != value { 27 | sendActions(for: .valueChanged) 28 | } 29 | if value <= minimumValue { 30 | topButton.setTitle("", for: UIControlState()) 31 | topButton.backgroundColor = UIColor.white 32 | } else { 33 | topButton.backgroundColor = UIColor(red: 238/255.0, green: 238/255.0, blue: 238/255.0, alpha: 1) 34 | topButton.alpha = 0.5 35 | } 36 | if value >= maximumValue { 37 | bottomButton.setTitle("", for: UIControlState()) 38 | } else { 39 | } 40 | } 41 | } 42 | open var minimumValue: Double = 0 43 | open var maximumValue: Double = 24 44 | open var stepValue: Double = 1 45 | open var autorepeat: Bool = true 46 | open var showIntegerIfDoubleIsInteger: Bool = true 47 | open var topButtonText: String = "" 48 | open var bottomButtonText: String = "1" 49 | open var buttonsTextColor: UIColor = UIColor(red: 0.0/255.0, green: 122.0/255.0, blue: 255.0/255.0, alpha: 1.0) 50 | open var buttonsBackgroundColor: UIColor = UIColor.white 51 | open var buttonsFont = UIFont(name: "AvenirNext-Bold", size: 20.0)! 52 | lazy var topButton: UIButton = { 53 | let button = UIButton() 54 | button.setTitle(self.topButtonText, for: UIControlState()) 55 | button.setTitleColor(self.buttonsTextColor, for: UIControlState()) 56 | button.backgroundColor = self.buttonsBackgroundColor 57 | button.titleLabel?.font = self.buttonsFont 58 | // button.contentHorizontalAlignment = .Left 59 | // button.contentVerticalAlignment = .Top 60 | // button.titleEdgeInsets = UIEdgeInsetsMake(10.0, 10.0, 0.0, 0.0) 61 | button.addTarget(self, action: #selector(PFStepper.topButtonTouchDown(_:)), for: .touchDown) 62 | button.addTarget(self, action: #selector(PFStepper.buttonTouchUp(_:)), for: UIControlEvents.touchUpInside) 63 | button.addTarget(self, action: #selector(PFStepper.buttonTouchUp(_:)), for: UIControlEvents.touchUpOutside) 64 | return button 65 | }() 66 | lazy var bottomButton: UIButton = { 67 | let button = UIButton() 68 | button.setTitle(self.bottomButtonText, for: UIControlState()) 69 | button.setTitleColor(self.buttonsTextColor, for: UIControlState()) 70 | button.backgroundColor = self.buttonsBackgroundColor 71 | button.titleLabel?.font = self.buttonsFont 72 | button.addTarget(self, action: #selector(PFStepper.bottomButtonTouchDown(_:)), for: .touchDown) 73 | button.addTarget(self, action: #selector(PFStepper.buttonTouchUp(_:)), for: UIControlEvents.touchUpInside) 74 | button.addTarget(self, action: #selector(PFStepper.buttonTouchUp(_:)), for: UIControlEvents.touchUpOutside) 75 | return button 76 | }() 77 | 78 | enum StepperState { 79 | case stable, shouldIncrease, shouldDecrease 80 | } 81 | 82 | var stepperState = StepperState.stable { 83 | didSet { 84 | if stepperState != .stable { 85 | updateValue() 86 | if autorepeat { 87 | scheduleTimer() 88 | } 89 | } 90 | } 91 | } 92 | 93 | let limitHitAnimationDuration = TimeInterval(0.1) 94 | var timer: Timer? 95 | 96 | /** When UIStepper reaches its top speed, it alters the value with a time interval of ~0.05 sec. 97 | The user pressing and holding on the stepper repeatedly: 98 | - First 2.5 sec, the stepper changes the value every 0.5 sec. 99 | - For the next 1.5 sec, it changes the value every 0.1 sec. 100 | - Then, every 0.05 sec. 101 | */ 102 | let timerInterval = TimeInterval(0.05) 103 | 104 | /// Check the handleTimerFire: function. While it is counting the number of fires, it decreases the mod value so that the value is altered more frequently. 105 | var timerFireCount = 0 106 | var timerFireCountModulo: Int { 107 | if timerFireCount > 80 { 108 | return 1 // 0.05 sec * 1 = 0.05 sec 109 | } else if timerFireCount > 50 { 110 | return 2 // 0.05 sec * 2 = 0.1 sec 111 | } else { 112 | return 10 // 0.05 sec * 10 = 0.5 sec 113 | } 114 | } 115 | 116 | required public init?(coder aDecoder: NSCoder) { 117 | super.init(coder: aDecoder) 118 | setup() 119 | } 120 | 121 | public override init(frame: CGRect) { 122 | super.init(frame: frame) 123 | setup() 124 | } 125 | 126 | func setup() { 127 | addSubview(topButton) 128 | addSubview(bottomButton) 129 | 130 | backgroundColor = buttonsBackgroundColor 131 | NotificationCenter.default.addObserver(self, selector: #selector(PFStepper.reset), name: NSNotification.Name.UIApplicationWillResignActive, object: nil) 132 | } 133 | 134 | open override func layoutSubviews() { 135 | let buttonWidth = bounds.size.width 136 | 137 | topButton.frame = CGRect(x: 0, y: 0, width: buttonWidth, height: bounds.size.height / 2) 138 | bottomButton.frame = CGRect(x: 0, y: bounds.size.height / 2, width: buttonWidth, height: bounds.size.height / 2) 139 | } 140 | 141 | func updateValue() { 142 | if stepperState == .shouldIncrease { 143 | value += stepValue 144 | } else if stepperState == .shouldDecrease { 145 | value -= stepValue 146 | } 147 | } 148 | 149 | deinit { 150 | resetTimer() 151 | NotificationCenter.default.removeObserver(self) 152 | } 153 | } 154 | 155 | // MARK: - Button Events 156 | extension PFStepper { 157 | func reset() { 158 | stepperState = .stable 159 | resetTimer() 160 | 161 | topButton.isEnabled = true 162 | bottomButton.isEnabled = true 163 | } 164 | 165 | func topButtonTouchDown(_ button: UIButton) { 166 | bottomButton.isEnabled = false 167 | resetTimer() 168 | 169 | if value == minimumValue { 170 | button.setTitle("", for: UIControlState()) 171 | } else { 172 | stepperState = .shouldDecrease 173 | } 174 | 175 | } 176 | 177 | func bottomButtonTouchDown(_ button: UIButton) { 178 | topButton.isEnabled = false 179 | resetTimer() 180 | 181 | if value == maximumValue { 182 | button.setTitle("", for: UIControlState()) 183 | } else { 184 | stepperState = .shouldIncrease 185 | } 186 | } 187 | 188 | func buttonTouchUp(_ button: UIButton) { 189 | reset() 190 | } 191 | } 192 | 193 | // MARK: - Timer 194 | extension PFStepper { 195 | func handleTimerFire(_ timer: Timer) { 196 | timerFireCount += 1 197 | 198 | if timerFireCount % timerFireCountModulo == 0 { 199 | updateValue() 200 | } 201 | } 202 | 203 | func scheduleTimer() { 204 | timer = Timer.scheduledTimer(timeInterval: timerInterval, target: self, selector: #selector(PFStepper.handleTimerFire(_:)), userInfo: nil, repeats: true) 205 | } 206 | 207 | func resetTimer() { 208 | if let timer = timer { 209 | timer.invalidate() 210 | self.timer = nil 211 | timerFireCount = 0 212 | } 213 | } 214 | } 215 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2015 Cee Cirno 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the"Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /PFStepper.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "PFStepper" 3 | s.version = "2.0.0" 4 | s.summary = "It may be the most elegant stepper you have ever had!" 5 | s.homepage = "https://github.com/PerfectFreeze/PFStepper" 6 | s.license = { :type => "MIT", :file => "LICENSE" } 7 | s.author = { "Cee" => "cee@chu2byo.com" } 8 | s.social_media_url = "https://twitter.com/Ceecirno" 9 | s.platform = :ios, "8.0" 10 | s.source = { :git => "https://github.com/PerfectFreeze/PFStepper.git", :tag => "v#{s.version.to_s}" } 11 | s.source_files = "Class/*.swift" 12 | s.requires_arc = true 13 | end -------------------------------------------------------------------------------- /PFStepperDemo/PFStepperDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 92165C931C2A67A500274852 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92165C921C2A67A500274852 /* AppDelegate.swift */; }; 11 | 92165C951C2A67A500274852 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92165C941C2A67A500274852 /* ViewController.swift */; }; 12 | 92165C981C2A67A500274852 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 92165C961C2A67A500274852 /* Main.storyboard */; }; 13 | 92165C9A1C2A67A500274852 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 92165C991C2A67A500274852 /* Assets.xcassets */; }; 14 | 92165C9D1C2A67A500274852 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 92165C9B1C2A67A500274852 /* LaunchScreen.storyboard */; }; 15 | 9232BFFB1DA895FC00B4EF82 /* PFStepper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9232BFFA1DA895FC00B4EF82 /* PFStepper.swift */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | 92165C8F1C2A67A500274852 /* PFStepperDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PFStepperDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | 92165C921C2A67A500274852 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 21 | 92165C941C2A67A500274852 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 22 | 92165C971C2A67A500274852 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 23 | 92165C991C2A67A500274852 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 24 | 92165C9C1C2A67A500274852 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 25 | 92165C9E1C2A67A500274852 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 26 | 9232BFFA1DA895FC00B4EF82 /* PFStepper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PFStepper.swift; sourceTree = ""; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | 92165C8C1C2A67A500274852 /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | ); 35 | runOnlyForDeploymentPostprocessing = 0; 36 | }; 37 | /* End PBXFrameworksBuildPhase section */ 38 | 39 | /* Begin PBXGroup section */ 40 | 92165C861C2A67A500274852 = { 41 | isa = PBXGroup; 42 | children = ( 43 | 9232BFF91DA895FC00B4EF82 /* Class */, 44 | 92165C911C2A67A500274852 /* PFStepperDemo */, 45 | 92165C901C2A67A500274852 /* Products */, 46 | ); 47 | sourceTree = ""; 48 | }; 49 | 92165C901C2A67A500274852 /* Products */ = { 50 | isa = PBXGroup; 51 | children = ( 52 | 92165C8F1C2A67A500274852 /* PFStepperDemo.app */, 53 | ); 54 | name = Products; 55 | sourceTree = ""; 56 | }; 57 | 92165C911C2A67A500274852 /* PFStepperDemo */ = { 58 | isa = PBXGroup; 59 | children = ( 60 | 92165C921C2A67A500274852 /* AppDelegate.swift */, 61 | 92165C941C2A67A500274852 /* ViewController.swift */, 62 | 92165C961C2A67A500274852 /* Main.storyboard */, 63 | 92165C991C2A67A500274852 /* Assets.xcassets */, 64 | 92165C9B1C2A67A500274852 /* LaunchScreen.storyboard */, 65 | 92165C9E1C2A67A500274852 /* Info.plist */, 66 | ); 67 | path = PFStepperDemo; 68 | sourceTree = ""; 69 | }; 70 | 9232BFF91DA895FC00B4EF82 /* Class */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | 9232BFFA1DA895FC00B4EF82 /* PFStepper.swift */, 74 | ); 75 | name = Class; 76 | path = ../Class; 77 | sourceTree = ""; 78 | }; 79 | /* End PBXGroup section */ 80 | 81 | /* Begin PBXNativeTarget section */ 82 | 92165C8E1C2A67A500274852 /* PFStepperDemo */ = { 83 | isa = PBXNativeTarget; 84 | buildConfigurationList = 92165CB71C2A67A500274852 /* Build configuration list for PBXNativeTarget "PFStepperDemo" */; 85 | buildPhases = ( 86 | 92165C8B1C2A67A500274852 /* Sources */, 87 | 92165C8C1C2A67A500274852 /* Frameworks */, 88 | 92165C8D1C2A67A500274852 /* Resources */, 89 | ); 90 | buildRules = ( 91 | ); 92 | dependencies = ( 93 | ); 94 | name = PFStepperDemo; 95 | productName = PFStepperDemo; 96 | productReference = 92165C8F1C2A67A500274852 /* PFStepperDemo.app */; 97 | productType = "com.apple.product-type.application"; 98 | }; 99 | /* End PBXNativeTarget section */ 100 | 101 | /* Begin PBXProject section */ 102 | 92165C871C2A67A500274852 /* Project object */ = { 103 | isa = PBXProject; 104 | attributes = { 105 | LastSwiftUpdateCheck = 0720; 106 | LastUpgradeCheck = 0800; 107 | ORGANIZATIONNAME = Cee; 108 | TargetAttributes = { 109 | 92165C8E1C2A67A500274852 = { 110 | CreatedOnToolsVersion = 7.2; 111 | LastSwiftMigration = 0800; 112 | }; 113 | }; 114 | }; 115 | buildConfigurationList = 92165C8A1C2A67A500274852 /* Build configuration list for PBXProject "PFStepperDemo" */; 116 | compatibilityVersion = "Xcode 3.2"; 117 | developmentRegion = English; 118 | hasScannedForEncodings = 0; 119 | knownRegions = ( 120 | en, 121 | Base, 122 | ); 123 | mainGroup = 92165C861C2A67A500274852; 124 | productRefGroup = 92165C901C2A67A500274852 /* Products */; 125 | projectDirPath = ""; 126 | projectRoot = ""; 127 | targets = ( 128 | 92165C8E1C2A67A500274852 /* PFStepperDemo */, 129 | ); 130 | }; 131 | /* End PBXProject section */ 132 | 133 | /* Begin PBXResourcesBuildPhase section */ 134 | 92165C8D1C2A67A500274852 /* Resources */ = { 135 | isa = PBXResourcesBuildPhase; 136 | buildActionMask = 2147483647; 137 | files = ( 138 | 92165C9D1C2A67A500274852 /* LaunchScreen.storyboard in Resources */, 139 | 92165C9A1C2A67A500274852 /* Assets.xcassets in Resources */, 140 | 92165C981C2A67A500274852 /* Main.storyboard in Resources */, 141 | ); 142 | runOnlyForDeploymentPostprocessing = 0; 143 | }; 144 | /* End PBXResourcesBuildPhase section */ 145 | 146 | /* Begin PBXSourcesBuildPhase section */ 147 | 92165C8B1C2A67A500274852 /* Sources */ = { 148 | isa = PBXSourcesBuildPhase; 149 | buildActionMask = 2147483647; 150 | files = ( 151 | 92165C951C2A67A500274852 /* ViewController.swift in Sources */, 152 | 92165C931C2A67A500274852 /* AppDelegate.swift in Sources */, 153 | 9232BFFB1DA895FC00B4EF82 /* PFStepper.swift in Sources */, 154 | ); 155 | runOnlyForDeploymentPostprocessing = 0; 156 | }; 157 | /* End PBXSourcesBuildPhase section */ 158 | 159 | /* Begin PBXVariantGroup section */ 160 | 92165C961C2A67A500274852 /* Main.storyboard */ = { 161 | isa = PBXVariantGroup; 162 | children = ( 163 | 92165C971C2A67A500274852 /* Base */, 164 | ); 165 | name = Main.storyboard; 166 | sourceTree = ""; 167 | }; 168 | 92165C9B1C2A67A500274852 /* LaunchScreen.storyboard */ = { 169 | isa = PBXVariantGroup; 170 | children = ( 171 | 92165C9C1C2A67A500274852 /* Base */, 172 | ); 173 | name = LaunchScreen.storyboard; 174 | sourceTree = ""; 175 | }; 176 | /* End PBXVariantGroup section */ 177 | 178 | /* Begin XCBuildConfiguration section */ 179 | 92165CB51C2A67A500274852 /* Debug */ = { 180 | isa = XCBuildConfiguration; 181 | buildSettings = { 182 | ALWAYS_SEARCH_USER_PATHS = NO; 183 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 184 | CLANG_CXX_LIBRARY = "libc++"; 185 | CLANG_ENABLE_MODULES = YES; 186 | CLANG_ENABLE_OBJC_ARC = YES; 187 | CLANG_WARN_BOOL_CONVERSION = YES; 188 | CLANG_WARN_CONSTANT_CONVERSION = YES; 189 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 190 | CLANG_WARN_EMPTY_BODY = YES; 191 | CLANG_WARN_ENUM_CONVERSION = YES; 192 | CLANG_WARN_INFINITE_RECURSION = YES; 193 | CLANG_WARN_INT_CONVERSION = YES; 194 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 195 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 196 | CLANG_WARN_UNREACHABLE_CODE = YES; 197 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 198 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 199 | COPY_PHASE_STRIP = NO; 200 | DEBUG_INFORMATION_FORMAT = dwarf; 201 | ENABLE_STRICT_OBJC_MSGSEND = YES; 202 | ENABLE_TESTABILITY = YES; 203 | GCC_C_LANGUAGE_STANDARD = gnu99; 204 | GCC_DYNAMIC_NO_PIC = NO; 205 | GCC_NO_COMMON_BLOCKS = YES; 206 | GCC_OPTIMIZATION_LEVEL = 0; 207 | GCC_PREPROCESSOR_DEFINITIONS = ( 208 | "DEBUG=1", 209 | "$(inherited)", 210 | ); 211 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 212 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 213 | GCC_WARN_UNDECLARED_SELECTOR = YES; 214 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 215 | GCC_WARN_UNUSED_FUNCTION = YES; 216 | GCC_WARN_UNUSED_VARIABLE = YES; 217 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 218 | MTL_ENABLE_DEBUG_INFO = YES; 219 | ONLY_ACTIVE_ARCH = YES; 220 | SDKROOT = iphoneos; 221 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 222 | SWIFT_VERSION = 3.0; 223 | }; 224 | name = Debug; 225 | }; 226 | 92165CB61C2A67A500274852 /* Release */ = { 227 | isa = XCBuildConfiguration; 228 | buildSettings = { 229 | ALWAYS_SEARCH_USER_PATHS = NO; 230 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 231 | CLANG_CXX_LIBRARY = "libc++"; 232 | CLANG_ENABLE_MODULES = YES; 233 | CLANG_ENABLE_OBJC_ARC = YES; 234 | CLANG_WARN_BOOL_CONVERSION = YES; 235 | CLANG_WARN_CONSTANT_CONVERSION = YES; 236 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 237 | CLANG_WARN_EMPTY_BODY = YES; 238 | CLANG_WARN_ENUM_CONVERSION = YES; 239 | CLANG_WARN_INFINITE_RECURSION = YES; 240 | CLANG_WARN_INT_CONVERSION = YES; 241 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 242 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 243 | CLANG_WARN_UNREACHABLE_CODE = YES; 244 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 245 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 246 | COPY_PHASE_STRIP = NO; 247 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 248 | ENABLE_NS_ASSERTIONS = NO; 249 | ENABLE_STRICT_OBJC_MSGSEND = YES; 250 | GCC_C_LANGUAGE_STANDARD = gnu99; 251 | GCC_NO_COMMON_BLOCKS = YES; 252 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 253 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 254 | GCC_WARN_UNDECLARED_SELECTOR = YES; 255 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 256 | GCC_WARN_UNUSED_FUNCTION = YES; 257 | GCC_WARN_UNUSED_VARIABLE = YES; 258 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 259 | MTL_ENABLE_DEBUG_INFO = NO; 260 | SDKROOT = iphoneos; 261 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 262 | SWIFT_VERSION = 3.0; 263 | VALIDATE_PRODUCT = YES; 264 | }; 265 | name = Release; 266 | }; 267 | 92165CB81C2A67A500274852 /* Debug */ = { 268 | isa = XCBuildConfiguration; 269 | buildSettings = { 270 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 271 | INFOPLIST_FILE = PFStepperDemo/Info.plist; 272 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 273 | PRODUCT_BUNDLE_IDENTIFIER = io.Cee.PFStepperDemo; 274 | PRODUCT_NAME = "$(TARGET_NAME)"; 275 | SWIFT_VERSION = 3.0; 276 | }; 277 | name = Debug; 278 | }; 279 | 92165CB91C2A67A500274852 /* Release */ = { 280 | isa = XCBuildConfiguration; 281 | buildSettings = { 282 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 283 | INFOPLIST_FILE = PFStepperDemo/Info.plist; 284 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 285 | PRODUCT_BUNDLE_IDENTIFIER = io.Cee.PFStepperDemo; 286 | PRODUCT_NAME = "$(TARGET_NAME)"; 287 | SWIFT_VERSION = 3.0; 288 | }; 289 | name = Release; 290 | }; 291 | /* End XCBuildConfiguration section */ 292 | 293 | /* Begin XCConfigurationList section */ 294 | 92165C8A1C2A67A500274852 /* Build configuration list for PBXProject "PFStepperDemo" */ = { 295 | isa = XCConfigurationList; 296 | buildConfigurations = ( 297 | 92165CB51C2A67A500274852 /* Debug */, 298 | 92165CB61C2A67A500274852 /* Release */, 299 | ); 300 | defaultConfigurationIsVisible = 0; 301 | defaultConfigurationName = Release; 302 | }; 303 | 92165CB71C2A67A500274852 /* Build configuration list for PBXNativeTarget "PFStepperDemo" */ = { 304 | isa = XCConfigurationList; 305 | buildConfigurations = ( 306 | 92165CB81C2A67A500274852 /* Debug */, 307 | 92165CB91C2A67A500274852 /* Release */, 308 | ); 309 | defaultConfigurationIsVisible = 0; 310 | defaultConfigurationName = Release; 311 | }; 312 | /* End XCConfigurationList section */ 313 | }; 314 | rootObject = 92165C871C2A67A500274852 /* Project object */; 315 | } 316 | -------------------------------------------------------------------------------- /PFStepperDemo/PFStepperDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PFStepperDemo/PFStepperDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // PFStepperDemo 4 | // 5 | // Created by Cee on 23/12/2015. 6 | // Copyright © 2015 Cee. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /PFStepperDemo/PFStepperDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /PFStepperDemo/PFStepperDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /PFStepperDemo/PFStepperDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /PFStepperDemo/PFStepperDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /PFStepperDemo/PFStepperDemo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // PFStepperDemo 4 | // 5 | // Created by Cee on 23/12/2015. 6 | // Copyright © 2015 Cee. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | let stepper = PFStepper(frame: CGRect(x: (view.bounds.width - 80) / 2, y: (view.bounds.height - 80) / 2, width: 80, height: 80)) 16 | view.addSubview(stepper) 17 | view.backgroundColor = UIColor.lightGray 18 | // Do any additional setup after loading the view, typically from a nib. 19 | } 20 | 21 | override func didReceiveMemoryWarning() { 22 | super.didReceiveMemoryWarning() 23 | // Dispose of any resources that can be recreated. 24 | } 25 | 26 | 27 | } 28 | 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PFStepper 2 | 3 | [![Version](https://img.shields.io/cocoapods/v/PFStepper.svg?style=flat)](http://cocoapods.org/pods/PFStepper) 4 | [![License](https://img.shields.io/cocoapods/l/PFStepper.svg?style=flat)](http://cocoapods.org/pods/PFStepper) 5 | [![Platform](https://img.shields.io/cocoapods/p/PFStepper.svg?style=flat)](http://cocoapods.org/pods/PFStepper) 6 | 7 | It may be the most elegant stepper you have ever had! 8 | 9 | ![Sample](Sample.gif) 10 | 11 | ## Usage 12 | 13 | To be written. 14 | 15 | ## Todo 16 | 17 | - [ ] Documenting 18 | - [ ] @IBDesignable supporting 19 | - [ ] Animations 20 | - [ ] Customizable 21 | - [ ] Testing 22 | 23 | ## Special Thanks 24 | 25 | - [GMStepper](https://github.com/gmertk/GMStepper) 26 | 27 | ## License 28 | 29 | Released under the MIT License. -------------------------------------------------------------------------------- /Sample.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectFreeze/PFStepper/1dbdc1a9690a349e06580d35e8e1c6d6a633e08b/Sample.gif --------------------------------------------------------------------------------