@@ -24,7 +24,7 @@ import UIKit
2424 }
2525
2626 if oldValue != value {
27− sendActionsForControlEvents(.ValueChanged)
27+ sendActions(for: .valueChanged)
2828 }
2929 }
3030 }
@@ -55,22 +55,22 @@ import UIKit
5555 /// Text on the left button. Be sure that it fits in the button. Defaults to "−".
5656 @IBInspectable public var leftButtonText: String = "−" {
5757 didSet {
58− leftButton.setTitle(leftButtonText, forState: .Normal)
58+ leftButton.setTitle(leftButtonText, for: .normal)
5959 }
6060 }
6161
6262 /// Text on the right button. Be sure that it fits in the button. Defaults to "+".
6363 @IBInspectable public var rightButtonText: String = "+" {
6464 didSet {
65− rightButton.setTitle(rightButtonText, forState: .Normal)
65+ rightButton.setTitle(rightButtonText, for: .normal)
6666 }
6767 }
6868
6969 /// Text color of the buttons. Defaults to white.
70− @IBInspectable public var buttonsTextColor: UIColor = UIColor.whiteColor() {
70+ @IBInspectable public var buttonsTextColor: UIColor = UIColor.white {
7171 didSet {
7272 for button in [leftButton, rightButton] {
73− button.setTitleColor(buttonsTextColor, forState: .Normal)
73+ button.setTitleColor(buttonsTextColor, for: .normal)
7474 }
7575 }
7676 }
@@ -95,7 +95,7 @@ import UIKit
9595 }
9696
9797 /// Text color of the middle label. Defaults to white.
98− @IBInspectable public var labelTextColor: UIColor = UIColor.whiteColor() {
98+ @IBInspectable public var labelTextColor: UIColor = UIColor.white {
9999 didSet {
100100 label.textColor = labelTextColor
101101 }
@@ -132,10 +132,10 @@ import UIKit
132132 }
133133
134134 /// Color of the border of the stepper and middle label's layer. Defaults to clear color.
135− @IBInspectable public var borderColor: UIColor = UIColor.clearColor() {
135+ @IBInspectable public var borderColor: UIColor = UIColor.clear {
136136 didSet {
137− layer.borderColor = borderColor.CGColor
138− label.layer.borderColor = borderColor.CGColor
137+ layer.borderColor = borderColor.cgColor
138+ label.layer.borderColor = borderColor.cgColor
139139 }
140140 }
141141
@@ -156,38 +156,38 @@ import UIKit
156156 let labelSlideLength: CGFloat = 5
157157
158158 /// Duration of the sliding animation
159− let labelSlideDuration = NSTimeInterval(0.1)
159+ let labelSlideDuration = TimeInterval(0.1)
160160
161161 /// Duration of the animation when the value hits the limit.
162− let limitHitAnimationDuration = NSTimeInterval(0.1)
162+ let limitHitAnimationDuration = TimeInterval(0.1)
163163
164164 lazy var leftButton: UIButton = {
165165 let button = UIButton()
166− button.setTitle(self.leftButtonText, forState: .Normal)
167− button.setTitleColor(self.buttonsTextColor, forState: .Normal)
166+ button.setTitle(self.leftButtonText, for: .normal)
167+ button.setTitleColor(self.buttonsTextColor, for: .normal)
168168 button.backgroundColor = self.buttonsBackgroundColor
169169 button.titleLabel?.font = self.buttonsFont
170− button.addTarget(self, action: #selector(GMStepper.leftButtonTouchDown), forControlEvents: .TouchDown)
171− button.addTarget(self, action: #selector(GMStepper.buttonTouchUp), forControlEvents: .TouchUpInside)
172− button.addTarget(self, action: #selector(GMStepper.buttonTouchUp), forControlEvents: .TouchUpOutside)
170+ button.addTarget(self, action: #selector(GMStepper.leftButtonTouchDown), for: .touchDown)
171+ button.addTarget(self, action: #selector(GMStepper.buttonTouchUp), for: .touchUpInside)
172+ button.addTarget(self, action: #selector(GMStepper.buttonTouchUp), for: .touchUpOutside)
173173 return button
174174 }()
175175
176176 lazy var rightButton: UIButton = {
177177 let button = UIButton()
178− button.setTitle(self.rightButtonText, forState: .Normal)
179− button.setTitleColor(self.buttonsTextColor, forState: .Normal)
178+ button.setTitle(self.rightButtonText, for: .normal)
179+ button.setTitleColor(self.buttonsTextColor, for: .normal)
180180 button.backgroundColor = self.buttonsBackgroundColor
181181 button.titleLabel?.font = self.buttonsFont
182− button.addTarget(self, action: #selector(GMStepper.rightButtonTouchDown), forControlEvents: .TouchDown)
183− button.addTarget(self, action: #selector(GMStepper.buttonTouchUp), forControlEvents: .TouchUpInside)
184− button.addTarget(self, action: #selector(GMStepper.buttonTouchUp), forControlEvents: .TouchUpOutside)
182+ button.addTarget(self, action: #selector(GMStepper.rightButtonTouchDown), for: .touchDown)
183+ button.addTarget(self, action: #selector(GMStepper.buttonTouchUp), for: .touchUpInside)
184+ button.addTarget(self, action: #selector(GMStepper.buttonTouchUp), for: .touchUpOutside)
185185 return button
186186 }()
187187
188188 lazy var label: UILabel = {
189189 let label = UILabel()
190− label.textAlignment = .Center
190+ label.textAlignment = .center
191191 if self.showIntegerIfDoubleIsInteger && floor(self.value) == self.value {
192192 label.text = String(stringInterpolationSegment: Int(self.value))
193193 } else {
@@ -196,7 +196,7 @@ import UIKit
196196 label.textColor = self.labelTextColor
197197 label.backgroundColor = self.labelBackgroundColor
198198 label.font = self.labelFont
199− label.userInteractionEnabled = true
199+ label.isUserInteractionEnabled = true
200200 let panRecognizer = UIPanGestureRecognizer(target: self, action: #selector(GMStepper.handlePan))
201201 panRecognizer.maximumNumberOfTouches = 1
202202 label.addGestureRecognizer(panRecognizer)
@@ -227,7 +227,7 @@ import UIKit
227227 }
228228
229229 /// Timer used for autorepeat option
230− var timer: NSTimer?
230+ var timer: Timer?
231231
232232 /** When UIStepper reaches its top speed, it alters the value with a time interval of ~0.05 sec.
233233 The user pressing and holding on the stepper repeatedly:
@@ -235,7 +235,7 @@ import UIKit
235235 - For the next 1.5 sec, it changes the value every 0.1 sec.
236236 - Then, every 0.05 sec.
237237 */
238− let timerInterval = NSTimeInterval(0.05)
238+ let timerInterval = TimeInterval(0.05)
239239
240240 /// 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.
241241 var timerFireCount = 0
@@ -268,7 +268,7 @@ import UIKit
268268 layer.cornerRadius = cornerRadius
269269 clipsToBounds = true
270270
271− NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(GMStepper.reset), name: UIApplicationWillResignActiveNotification, object: nil)
271+ NotificationCenter.default.addObserver(self, selector: #selector(GMStepper.reset), name: NSNotification.Name.UIApplicationWillResignActive, object: nil)
272272 }
273273
274274 public override func layoutSubviews() {
@@ -294,7 +294,7 @@ import UIKit
294294
295295 deinit {
296296 resetTimer()
297− NSNotificationCenter.defaultCenter().removeObserver(self)
297+ NotificationCenter.default.removeObserver(self)
298298 }
299299
300300 /// 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.
@@ -315,15 +315,15 @@ import UIKit
315315extension GMStepper {
316316 func handlePan(gesture: UIPanGestureRecognizer) {
317317 switch gesture.state {
318− case .Began:
319− leftButton.enabled = false
320− rightButton.enabled = false
321− case .Changed:
322− let translation = gesture.translationInView(label)
323− gesture.setTranslation(CGPointZero, inView: label)
318+ case .began:
319+ leftButton.isEnabled = false
320+ rightButton.isEnabled = false
321+ case .changed:
322+ let translation = gesture.translation(in: label)
323+ gesture.setTranslation(CGPoint.zero, in: label)
324324
325− let slidingRight = gesture.velocityInView(label).x > 0
326− let slidingLeft = gesture.velocityInView(label).x < 0
325+ let slidingRight = gesture.velocity(in: label).x > 0
326+ let slidingLeft = gesture.velocity(in: label).x < 0
327327
328328 // Move the label with pan
329329 if slidingRight {
@@ -356,7 +356,7 @@ extension GMStepper {
356356 self.rightButton.backgroundColor = self.buttonsBackgroundColor
357357 self.leftButton.backgroundColor = self.buttonsBackgroundColor
358358 }
359− case .Ended, .Cancelled, .Failed:
359+ case .ended, .cancelled, .failed:
360360 reset()
361361 default:
362362 break
@@ -368,11 +368,11 @@ extension GMStepper {
368368 stepperState = .Stable
369369 resetTimer()
370370
371− leftButton.enabled = true
372− rightButton.enabled = true
373− label.userInteractionEnabled = true
371+ leftButton.isEnabled = true
372+ rightButton.isEnabled = true
373+ label.isUserInteractionEnabled = true
374374
375− UIView.animateWithDuration(self.labelSlideDuration, animations: {
375+ UIView.animate(withDuration: self.labelSlideDuration, animations: {
376376 self.label.center = self.labelOriginalCenter
377377 self.rightButton.backgroundColor = self.buttonsBackgroundColor
378378 self.leftButton.backgroundColor = self.buttonsBackgroundColor
@@ -383,8 +383,8 @@ extension GMStepper {
383383// MARK: Button Events
384384extension GMStepper {
385385 func leftButtonTouchDown(button: UIButton) {
386− rightButton.enabled = false
387− label.userInteractionEnabled = false
386+ rightButton.isEnabled = false
387+ label.isUserInteractionEnabled = false
388388 resetTimer()
389389
390390 if value == minimumValue {
@@ -397,8 +397,8 @@ extension GMStepper {
397397 }
398398
399399 func rightButtonTouchDown(button: UIButton) {
400− leftButton.enabled = false
401− label.userInteractionEnabled = false
400+ leftButton.isEnabled = false
401+ label.isUserInteractionEnabled = false
402402 resetTimer()
403403
404404 if value == maximumValue {
@@ -418,20 +418,20 @@ extension GMStepper {
418418extension GMStepper {
419419
420420 func animateSlideLeft() {
421− UIView.animateWithDuration(labelSlideDuration) {
421+ UIView.animate(withDuration: labelSlideDuration) {
422422 self.label.center.x -= self.labelSlideLength
423423 }
424424 }
425425
426426 func animateSlideRight() {
427− UIView.animateWithDuration(labelSlideDuration) {
427+ UIView.animate(withDuration: labelSlideDuration) {
428428 self.label.center.x += self.labelSlideLength
429429 }
430430 }
431431
432432 func animateToOriginalPosition() {
433433 if self.label.center != self.labelOriginalCenter {
434− UIView.animateWithDuration(labelSlideDuration) {
434+ UIView.animate(withDuration: labelSlideDuration) {
435435 self.label.center = self.labelOriginalCenter
436436 }
437437 }
@@ -439,14 +439,14 @@ extension GMStepper {
439439
440440 func animateLimitHitIfNeeded() {
441441 if value == minimumValue {
442− animateLimitHitForButton(leftButton)
442+ animateLimitHitForButton(button: leftButton)
443443 } else if value == maximumValue {
444− animateLimitHitForButton(rightButton)
444+ animateLimitHitForButton(button: rightButton)
445445 }
446446 }
447447
448448 func animateLimitHitForButton(button: UIButton){
449− UIView.animateWithDuration(limitHitAnimationDuration) {
449+ UIView.animate(withDuration: limitHitAnimationDuration) {
450450 button.backgroundColor = self.limitHitAnimationColor
451451 }
452452 }
@@ -454,7 +454,7 @@ extension GMStepper {
454454
455455// MARK: Timer
456456extension GMStepper {
457− func handleTimerFire(timer: NSTimer) {
457+ func handleTimerFire(timer: Timer) {
458458 timerFireCount += 1
459459
460460 if timerFireCount % timerFireCountModulo == 0 {
@@ -463,7 +463,7 @@ extension GMStepper {
463463 }
464464
465465 func scheduleTimer() {
466− timer = NSTimer.scheduledTimerWithTimeInterval(timerInterval, target: self, selector: #selector(GMStepper.handleTimerFire), userInfo: nil, repeats: true)
466+ timer = Timer.scheduledTimer(timeInterval: timerInterval, target: self, selector: #selector(GMStepper.handleTimerFire), userInfo: nil, repeats: true)
467467 }
468468
469469 func resetTimer() {