@@ -11,59 +11,79 @@ import UIKit
1111@IBDesignable public class GMStepper: UIControl {
1212
1313 /// Current value of the stepper. Defaults to 0.
14− public var value = 0 {
14+ @objc @IBInspectable public var value: Double = 0 {
1515 didSet {
1616 value = min(maximumValue, max(minimumValue, value))
17− label.text = String(value)
17+
18+ let isInteger = floor(value) == value
19+
20+ //
21+ // If we have items, we will display them as steps
22+ //
23+
24+ if isInteger && stepValue == 1.0 && items.count > 0 {
25+ label.text = items[Int(value)]
26+ }
27+ else if showIntegerIfDoubleIsInteger && isInteger {
28+ label.text = String(stringInterpolationSegment: Int(value))
29+ } else {
30+ label.text = String(stringInterpolationSegment: value)
31+ }
1832
1933 if oldValue != value {
20− sendActionsForControlEvents(.ValueChanged)
34+ sendActions(for: .valueChanged)
2135 }
2236 }
2337 }
2438
2539 /// Minimum value. Must be less than maximumValue. Defaults to 0.
26− @IBInspectable public var minimumValue: Int = 0 {
40+ @objc @IBInspectable public var minimumValue: Double = 0 {
2741 didSet {
28− value = 0
42+ value = min(maximumValue, max(minimumValue, value))
2943 }
3044 }
3145
32− /// Maximum value. Must be more than minimumValue. Defaults to 10.
33− @IBInspectable public var maximumValue: Int = 10 {
46+ /// Maximum value. Must be more than minimumValue. Defaults to 100.
47+ @objc @IBInspectable public var maximumValue: Double = 100 {
3448 didSet {
35− value = 0
49+ value = min(maximumValue, max(minimumValue, value))
3650 }
3751 }
3852
39− /// The same as UIStepper's autorepeat. If true, holding on the buttons or the pan gesture repeatedly alters value. Defaults to true.
40− @IBInspectable public var autorepeat: Bool = true
53+ /// Step/Increment value as in UIStepper. Defaults to 1.
54+ @objc @IBInspectable public var stepValue: Double = 1
55+
56+ /// The same as UIStepper's autorepeat. If true, holding on the buttons or keeping the pan gesture alters the value repeatedly. Defaults to true.
57+ @objc @IBInspectable public var autorepeat: Bool = true
58+
59+ /// If the value is integer, it is shown without floating point.
60+ @objc @IBInspectable public var showIntegerIfDoubleIsInteger: Bool = true
4161
42− /// Text on the left button. Be sure that it fits in the button. Defaults to "-".
43− @IBInspectable public var leftButtonText: String = "-" {
62+ /// Text on the left button. Be sure that it fits in the button. Defaults to "−".
63+ @objc @IBInspectable public var leftButtonText: String = "−" {
4464 didSet {
45− leftButton.setTitle(leftButtonText, forState: .Normal)
65+ leftButton.setTitle(leftButtonText, for: .normal)
4666 }
4767 }
4868
4969 /// Text on the right button. Be sure that it fits in the button. Defaults to "+".
50− @IBInspectable public var rightButtonText: String = "+" {
70+ @objc @IBInspectable public var rightButtonText: String = "+" {
5171 didSet {
52− rightButton.setTitle(rightButtonText, forState: .Normal)
72+ rightButton.setTitle(rightButtonText, for: .normal)
5373 }
5474 }
5575
5676 /// Text color of the buttons. Defaults to white.
57− @IBInspectable public var buttonsTextColor: UIColor = UIColor.whiteColor() {
77+ @objc @IBInspectable public var buttonsTextColor: UIColor = UIColor.white {
5878 didSet {
5979 for button in [leftButton, rightButton] {
60− button.setTitleColor(buttonsTextColor, forState: .Normal)
80+ button.setTitleColor(buttonsTextColor, for: .normal)
6181 }
6282 }
6383 }
6484
6585 /// Background color of the buttons. Defaults to dark blue.
66− @IBInspectable public var buttonsBackgroundColor: UIColor = UIColor(red:0.21, green:0.5, blue:0.74, alpha:1) {
86+ @objc @IBInspectable public var buttonsBackgroundColor: UIColor = UIColor(red:0.21, green:0.5, blue:0.74, alpha:1) {
6787 didSet {
6888 for button in [leftButton, rightButton] {
6989 button.backgroundColor = buttonsBackgroundColor
@@ -73,7 +93,7 @@ import UIKit
7393 }
7494
7595 /// Font of the buttons. Defaults to AvenirNext-Bold, 20.0 points in size.
76− public var buttonsFont = UIFont(name: "AvenirNext-Bold", size: 20.0)! {
96+ @objc public var buttonsFont = UIFont(name: "AvenirNext-Bold", size: 20.0)! {
7797 didSet {
7898 for button in [leftButton, rightButton] {
7999 button.titleLabel?.font = buttonsFont
@@ -82,70 +102,174 @@ import UIKit
82102 }
83103
84104 /// Text color of the middle label. Defaults to white.
85− @IBInspectable public var labelTextColor: UIColor = UIColor.whiteColor() {
105+ @objc @IBInspectable public var labelTextColor: UIColor = UIColor.white {
86106 didSet {
87107 label.textColor = labelTextColor
88108 }
89109 }
90110
91111 /// Text color of the middle label. Defaults to lighter blue.
92− @IBInspectable public var labelBackgroundColor: UIColor = UIColor(red:0.26, green:0.6, blue:0.87, alpha:1) {
112+ @objc @IBInspectable public var labelBackgroundColor: UIColor = UIColor(red:0.26, green:0.6, blue:0.87, alpha:1) {
93113 didSet {
94114 label.backgroundColor = labelBackgroundColor
95115 }
96116 }
97117
98118 /// Font of the middle label. Defaults to AvenirNext-Bold, 25.0 points in size.
99− public var labelFont = UIFont(name: "AvenirNext-Bold", size: 25.0)! {
119+ @objc public var labelFont = UIFont(name: "AvenirNext-Bold", size: 25.0)! {
100120 didSet {
101121 label.font = labelFont
102122 }
103123 }
124+ /// Corner radius of the middle label. Defaults to 0.
125+ @objc @IBInspectable public var labelCornerRadius: CGFloat = 0 {
126+ didSet {
127+ label.layer.cornerRadius = labelCornerRadius
128+
129+ }
130+ }
104131
105132 /// Corner radius of the stepper's layer. Defaults to 4.0.
106− @IBInspectable public var cornerRadius: CGFloat = 4.0 {
133+ @objc @IBInspectable public var cornerRadius: CGFloat = 4.0 {
107134 didSet {
108135 layer.cornerRadius = cornerRadius
109136 clipsToBounds = true
110137 }
111138 }
139+
140+ /// Border width of the stepper and middle label's layer. Defaults to 0.0.
141+ @objc @IBInspectable public var borderWidth: CGFloat = 0.0 {
142+ didSet {
143+ layer.borderWidth = borderWidth
144+ label.layer.borderWidth = borderWidth
145+ }
146+ }
147+
148+ /// Color of the border of the stepper and middle label's layer. Defaults to clear color.
149+ @objc @IBInspectable public var borderColor: UIColor = UIColor.clear {
150+ didSet {
151+ layer.borderColor = borderColor.cgColor
152+ label.layer.borderColor = borderColor.cgColor
153+ }
154+ }
112155
113156 /// Percentage of the middle label's width. Must be between 0 and 1. Defaults to 0.5. Be sure that it is wide enough to show the value.
114− @IBInspectable public var labelWidthWeight: CGFloat = 0.5 {
157+ @objc @IBInspectable public var labelWidthWeight: CGFloat = 0.5 {
115158 didSet {
116159 labelWidthWeight = min(1, max(0, labelWidthWeight))
117160 setNeedsLayout()
118161 }
119162 }
120163
164+ /// Color of the flashing animation on the buttons in case the value hit the limit.
165+ @objc @IBInspectable public var limitHitAnimationColor: UIColor = UIColor(red:0.26, green:0.6, blue:0.87, alpha:1)
166+
121167 /**
122168 Width of the sliding animation. When buttons clicked, the middle label does a slide animation towards to the clicked button. Defaults to 5.
123169 */
124− private let labelSlideLength: CGFloat = 5
170+ let labelSlideLength: CGFloat = 5
125171
126172 /// Duration of the sliding animation
127− private let labelSlideDuration = NSTimeInterval(0.1)
173+ let labelSlideDuration = TimeInterval(0.1)
174+
175+ /// Duration of the animation when the value hits the limit.
176+ let limitHitAnimationDuration = TimeInterval(0.1)
177+
178+ lazy var leftButton: UIButton = {
179+ let button = UIButton()
180+ button.setTitle(self.leftButtonText, for: .normal)
181+ button.setTitleColor(self.buttonsTextColor, for: .normal)
182+ button.backgroundColor = self.buttonsBackgroundColor
183+ button.titleLabel?.font = self.buttonsFont
184+ button.addTarget(self, action: #selector(GMStepper.leftButtonTouchDown), for: .touchDown)
185+ button.addTarget(self, action: #selector(GMStepper.buttonTouchUp), for: .touchUpInside)
186+ button.addTarget(self, action: #selector(GMStepper.buttonTouchUp), for: .touchUpOutside)
187+ button.addTarget(self, action: #selector(GMStepper.buttonTouchUp), for: .touchCancel)
188+ return button
189+ }()
128190
129− /// Duration of the flashing animation when the value hits the limit.
130− private let limitHitAnimationDuration = NSTimeInterval(0.1)
191+ lazy var rightButton: UIButton = {
192+ let button = UIButton()
193+ button.setTitle(self.rightButtonText, for: .normal)
194+ button.setTitleColor(self.buttonsTextColor, for: .normal)
195+ button.backgroundColor = self.buttonsBackgroundColor
196+ button.titleLabel?.font = self.buttonsFont
197+ button.addTarget(self, action: #selector(GMStepper.rightButtonTouchDown), for: .touchDown)
198+ button.addTarget(self, action: #selector(GMStepper.buttonTouchUp), for: .touchUpInside)
199+ button.addTarget(self, action: #selector(GMStepper.buttonTouchUp), for: .touchUpOutside)
200+ button.addTarget(self, action: #selector(GMStepper.buttonTouchUp), for: .touchCancel)
201+ return button
202+ }()
131203
132− /// Color of the flashing animation on the buttons in case the value hit the limit.
133− @IBInspectable public var limitHitAnimationColor: UIColor = UIColor(red:0.26, green:0.6, blue:0.87, alpha:1)
204+ lazy var label: UILabel = {
205+ let label = UILabel()
206+ label.textAlignment = .center
207+ if self.showIntegerIfDoubleIsInteger && floor(self.value) == self.value {
208+ label.text = String(stringInterpolationSegment: Int(self.value))
209+ } else {
210+ label.text = String(stringInterpolationSegment: self.value)
211+ }
212+ label.textColor = self.labelTextColor
213+ label.backgroundColor = self.labelBackgroundColor
214+ label.font = self.labelFont
215+ label.layer.cornerRadius = self.labelCornerRadius
216+ label.layer.masksToBounds = true
217+ label.isUserInteractionEnabled = true
218+ let panRecognizer = UIPanGestureRecognizer(target: self, action: #selector(GMStepper.handlePan))
219+ panRecognizer.maximumNumberOfTouches = 1
220+ label.addGestureRecognizer(panRecognizer)
221+ return label
222+ }()
134223
135− private let leftButton = UIButton()
136− private let rightButton = UIButton()
137− private let label = UILabel()
224+ var labelOriginalCenter: CGPoint!
225+ var labelMaximumCenterX: CGFloat!
226+ var labelMinimumCenterX: CGFloat!
138227
139− private var labelOriginalCenter: CGPoint!
140− private var labelMaximumCenterX: CGFloat!
141− private var labelMinimumCenterX: CGFloat!
228+ enum LabelPanState {
229+ case Stable, HitRightEdge, HitLeftEdge
230+ }
231+ var panState = LabelPanState.Stable
142232
143− private enum LabelPanState {
144− case Stale, HitRightEdge, HitLeftEdge
233+ enum StepperState {
234+ case Stable, ShouldIncrease, ShouldDecrease
235+ }
236+ var stepperState = StepperState.Stable {
237+ didSet {
238+ if stepperState != .Stable {
239+ updateValue()
240+ if autorepeat {
241+ scheduleTimer()
242+ }
243+ }
244+ }
245+ }
246+
247+
248+ @objc public var items : [String] = [] {
249+ didSet {
250+ let isInteger = floor(value) == value
251+
252+ //
253+ // If we have items, we will display them as steps
254+ //
255+
256+ if isInteger && stepValue == 1.0 && items.count > 0 {
257+
258+ var value = Int(self.value)
259+
260+ if value >= items.count {
261+ value = items.count - 1
262+ self.value = Double(value)
263+ }
264+ else {
265+ label.text = items[value]
266+ }
267+ }
268+ }
145269 }
146− private var panState = LabelPanState.Stale
147270
148− private var timer: NSTimer?
271+ /// Timer used for autorepeat option
272+ var timer: Timer?
149273
150274 /** When UIStepper reaches its top speed, it alters the value with a time interval of ~0.05 sec.
151275 The user pressing and holding on the stepper repeatedly:
@@ -153,11 +277,11 @@ import UIKit
153277 - For the next 1.5 sec, it changes the value every 0.1 sec.
154278 - Then, every 0.05 sec.
155279 */
156− private let timerInterval = NSTimeInterval(0.05)
280+ let timerInterval = TimeInterval(0.05)
157281
158282 /// 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.
159− private var timerFireCount = 0
160− private var timerFireCountModulo: Int {
283+ var timerFireCount = 0
284+ var timerFireCountModulo: Int {
161285 if timerFireCount > 80 {
162286 return 1 // 0.05 sec * 1 = 0.05 sec
163287 } else if timerFireCount > 50 {
@@ -167,61 +291,27 @@ import UIKit
167291 }
168292 }
169293
170− lazy var printTimerGaps: () -> () = {
171− var prevTime: CFAbsoluteTime?
172−
173− return { _ in
174− var now = CFAbsoluteTimeGetCurrent()
175− if let prevTime = prevTime {
176− println(now - prevTime)
177− }
178− prevTime = now
179− }
180− }()
181−
182− required public init(coder aDecoder: NSCoder) {
294+ @objc required public init?(coder aDecoder: NSCoder) {
183295 super.init(coder: aDecoder)
184296 setup()
185297 }
186298
187− public override init(frame: CGRect) {
299+ @objc public override init(frame: CGRect) {
188300 super.init(frame: frame)
189301 setup()
190302 }
191303
192− private func setup() {
193− leftButton.setTitle(leftButtonText, forState: .Normal)
194− leftButton.setTitleColor(buttonsTextColor, forState: .Normal)
195− leftButton.backgroundColor = buttonsBackgroundColor
196− leftButton.titleLabel?.font = buttonsFont
197− leftButton.addTarget(self, action: "leftButtonTouchDown:", forControlEvents: .TouchDown)
198− leftButton.addTarget(self, action: "leftButtonTouchUp:", forControlEvents: UIControlEvents.TouchUpInside)
199− leftButton.addTarget(self, action: "leftButtonTouchUp:", forControlEvents: UIControlEvents.TouchUpOutside)
304+ func setup() {
200305 addSubview(leftButton)
201−
202− rightButton.setTitle(rightButtonText, forState: .Normal)
203− rightButton.setTitleColor(buttonsTextColor, forState: .Normal)
204− rightButton.backgroundColor = buttonsBackgroundColor
205− rightButton.titleLabel?.font = buttonsFont
206− rightButton.addTarget(self, action: "rightButtonTapped:", forControlEvents: .TouchDown)
207− rightButton.addTarget(self, action: "rightButtonTouchUp:", forControlEvents: UIControlEvents.TouchUpInside)
208− rightButton.addTarget(self, action: "rightButtonTouchUp:", forControlEvents: UIControlEvents.TouchUpOutside)
209306 addSubview(rightButton)
210−
211− label.textAlignment = .Center
212− label.text = String(value)
213− label.textColor = labelTextColor
214− label.backgroundColor = labelBackgroundColor
215− label.font = labelFont
216307 addSubview(label)
217308
218309 backgroundColor = buttonsBackgroundColor
219310 layer.cornerRadius = cornerRadius
220311 clipsToBounds = true
312+ labelOriginalCenter = label.center
221313
222− let panRecognizer = UIPanGestureRecognizer(target: self, action: "handlePan:")
223− label.userInteractionEnabled = true
224− label.addGestureRecognizer(panRecognizer)
314+ NotificationCenter.default.addObserver(self, selector: #selector(GMStepper.reset), name: NSNotification.Name.UIApplicationWillResignActive, object: nil)
225315 }
226316
227317 public override func layoutSubviews() {
@@ -237,16 +327,46 @@ import UIKit
237327 labelOriginalCenter = label.center
238328 }
239329
330+ func updateValue() {
331+ if stepperState == .ShouldIncrease {
332+ value += stepValue
333+ } else if stepperState == .ShouldDecrease {
334+ value -= stepValue
335+ }
336+ }
240337
338+ deinit {
339+ resetTimer()
340+ NotificationCenter.default.removeObserver(self)
341+ }
241342
242− @objc private func handlePan(gesture: UIPanGestureRecognizer) {
343+ /// Useful closure for logging the timer interval. You can call this in the timer handler to test the autorepeat option. Not used in the current implementation.
344+// lazy var printTimerGaps: () -> () = {
345+// var prevTime: CFAbsoluteTime?
346+//
347+// return { _ in
348+// var now = CFAbsoluteTimeGetCurrent()
349+// if let prevTime = prevTime {
350+// print(now - prevTime)
351+// }
352+// prevTime = now
353+// }
354+// }()
355+}
356+
357+// MARK: Pan Gesture
358+extension GMStepper {
359+ @objc func handlePan(gesture: UIPanGestureRecognizer) {
243360 switch gesture.state {
244− case .Changed:
245− var translation = gesture.translationInView(label)
246− gesture.setTranslation(CGPointZero, inView: label)
361+ case .began:
362+ leftButton.isEnabled = false
363+ rightButton.isEnabled = false
364+ case .changed:
365+ let translation = gesture.translation(in: label)
366+ gesture.setTranslation(CGPoint.zero, in: label)
247367
248− var slidingRight = gesture.velocityInView(label).x > 0
249− var slidingLeft = gesture.velocityInView(label).x < 0
368+ let slidingRight = gesture.velocity(in: label).x > 0
369+ let slidingLeft = gesture.velocity(in: label).x < 0
250370
251371 // Move the label with pan
252372 if slidingRight {
@@ -257,42 +377,45 @@ import UIKit
257377
258378 // When the label hits the edges, increase/decrease value and change button backgrounds
259379 if label.center.x == labelMaximumCenterX {
260−
261− // Increase only once for each pan gesture
380+ // If not hit the right edge before, increase the value and start the timer. If already hit the edge, do nothing. Timer will handle it.
262381 if panState != .HitRightEdge {
263− value += 1
382+ stepperState = .ShouldIncrease
264383 panState = .HitRightEdge
265384 }
266−
267− if value == maximumValue {
268− animateLimitHitForButton(rightButton)
269− }
385+
386+ animateLimitHitIfNeeded()
270387 } else if label.center.x == labelMinimumCenterX {
271−
272388 if panState != .HitLeftEdge {
273− value -= 1
389+ stepperState = .ShouldDecrease
274390 panState = .HitLeftEdge
275391 }
276392
277− if value == minimumValue {
278− animateLimitHitForButton(leftButton)
279− }
393+ animateLimitHitIfNeeded()
280394 } else {
281− leftButton.backgroundColor = buttonsBackgroundColor
282− rightButton.backgroundColor = buttonsBackgroundColor
283− }
395+ panState = .Stable
396+ stepperState = .Stable
397+ resetTimer()
284398
285− case .Ended:
399+ self.rightButton.backgroundColor = self.buttonsBackgroundColor
400+ self.leftButton.backgroundColor = self.buttonsBackgroundColor
401+ }
402+ case .ended, .cancelled, .failed:
286403 reset()
287404 default:
288405 break
289406 }
290407 }
291408
292− private func reset() {
293− panState = .Stale
409+ @objc func reset() {
410+ panState = .Stable
411+ stepperState = .Stable
412+ resetTimer()
413+
414+ leftButton.isEnabled = true
415+ rightButton.isEnabled = true
416+ label.isUserInteractionEnabled = true
294417
295− UIView.animateWithDuration(self.labelSlideDuration, animations: {
418+ UIView.animate(withDuration: self.labelSlideDuration, animations: {
296419 self.label.center = self.labelOriginalCenter
297420 self.rightButton.backgroundColor = self.buttonsBackgroundColor
298421 self.leftButton.backgroundColor = self.buttonsBackgroundColor
@@ -302,93 +425,91 @@ import UIKit
302425
303426// MARK: Button Events
304427extension GMStepper {
305− @objc private func leftButtonTouchDown(button: UIButton) {
428+ @objc func leftButtonTouchDown(button: UIButton) {
429+ rightButton.isEnabled = false
430+ label.isUserInteractionEnabled = false
431+ resetTimer()
432+
306433 if value == minimumValue {
307− animateLimitHitForButton(leftButton)
434+ animateLimitHitIfNeeded()
308435 } else {
309− value -= 1
310− if autorepeat {
311− scheduleTimerWithUserInfo(leftButton)
312− }
436+ stepperState = .ShouldDecrease
313437 animateSlideLeft()
314438 }
315− }
316439
317− @objc private func leftButtonTouchUp(button: UIButton) {
318− reset()
319− stopTimer()
320440 }
321441
322− @objc private func rightButtonTapped(button: UIButton) {
442+ @objc func rightButtonTouchDown(button: UIButton) {
443+ leftButton.isEnabled = false
444+ label.isUserInteractionEnabled = false
445+ resetTimer()
446+
323447 if value == maximumValue {
324− animateLimitHitForButton(rightButton)
448+ animateLimitHitIfNeeded()
325449 } else {
326− value += 1
327− if autorepeat {
328− scheduleTimerWithUserInfo(rightButton)
329− }
450+ stepperState = .ShouldIncrease
330451 animateSlideRight()
331452 }
332453 }
333454
334− @objc private func rightButtonTouchUp(button: UIButton) {
455+ @objc func buttonTouchUp(button: UIButton) {
335456 reset()
336− stopTimer()
337457 }
338458}
339459
340460// MARK: Animations
341461extension GMStepper {
342462
343− private func animateSlideLeft() {
344− UIView.animateWithDuration(labelSlideDuration) {
463+ func animateSlideLeft() {
464+ UIView.animate(withDuration: labelSlideDuration) {
345465 self.label.center.x -= self.labelSlideLength
346466 }
347467 }
348468
349− private func animateSlideRight() {
350− UIView.animateWithDuration(labelSlideDuration) {
469+ func animateSlideRight() {
470+ UIView.animate(withDuration: labelSlideDuration) {
351471 self.label.center.x += self.labelSlideLength
352472 }
353473 }
354474
355− private func animateToOriginalPosition() {
475+ func animateToOriginalPosition() {
356476 if self.label.center != self.labelOriginalCenter {
357− UIView.animateWithDuration(labelSlideDuration) {
477+ UIView.animate(withDuration: labelSlideDuration) {
358478 self.label.center = self.labelOriginalCenter
359479 }
360480 }
361481 }
362482
363− private func animateLimitHitForButton(button: UIButton){
364− UIView.animateWithDuration(limitHitAnimationDuration) {
365− button.backgroundColor = self.limitHitAnimationColor
483+ func animateLimitHitIfNeeded() {
484+ if value == minimumValue {
485+ animateLimitHitForButton(button: leftButton)
486+ } else if value == maximumValue {
487+ animateLimitHitForButton(button: rightButton)
366488 }
367489 }
368490
491+ func animateLimitHitForButton(button: UIButton){
492+ UIView.animate(withDuration: limitHitAnimationDuration) {
493+ button.backgroundColor = self.limitHitAnimationColor
494+ }
495+ }
369496}
370497
498+// MARK: Timer
371499extension GMStepper {
372− func handleTimerFire(timer: NSTimer) {
500+ @objc func handleTimerFire(timer: Timer) {
373501 timerFireCount += 1
374− if timerFireCount % timerFireCountModulo == 0 {
375502
376− if let button = timer.userInfo as? UIButton {
377− if button == leftButton {
378− value -= 1
379− } else {
380− value += 1
381− }
382− }
383−// printTimerGaps()
503+ if timerFireCount % timerFireCountModulo == 0 {
504+ updateValue()
384505 }
385506 }
386507
387− func scheduleTimerWithUserInfo(userInfo: AnyObject?) {
388− timer = NSTimer.scheduledTimerWithTimeInterval(timerInterval, target: self, selector: "handleTimerFire:", userInfo: userInfo, repeats: true)
508+ func scheduleTimer() {
509+ timer = Timer.scheduledTimer(timeInterval: timerInterval, target: self, selector: #selector(GMStepper.handleTimerFire), userInfo: nil, repeats: true)
389510 }
390511
391− func stopTimer() {
512+ func resetTimer() {
392513 if let timer = timer {
393514 timer.invalidate()
394515 self.timer = nil
@@ -397,4 +518,4 @@ extension GMStepper {
397518 }
398519
399520
400−}
521+}