TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Oct 2016 |
SPMSupports SPM | ✗ |
Maintained by Onur Ersel.
A stepper input library for iOS with cool animations.
Copy contents of stepr/stepr and stepr/images folders to your project. This library requires another library called anim, so you have to implement it as well.
You can initialize Stepr and add it to stage just like any other UIView
let stepr = Stepr()
self.view.addSubview(stepr)
Stepr both supports default frame placement and constraints.
var c : NSLayoutConstraint?
c = NSLayoutConstraint(item: stepr, attribute: .CenterX, relatedBy: .Equal, toItem: self.view, attribute: .CenterX, multiplier: 1, constant: 0)
self.view.addConstraint(c!)
c = NSLayoutConstraint(item: stepr, attribute: .CenterY, relatedBy: .Equal, toItem: self.view, attribute: .CenterY, multiplier: 1, constant: 0)
self.view.addConstraint(c!)
c = NSLayoutConstraint(item: stepr, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1, constant: 250)
self.view.addConstraint(c!)
c = NSLayoutConstraint(item: stepr, attribute: .Width, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1, constant: 100)
self.view.addConstraint(c!)
You can replace up and down buttons with your custom buttons. You just need to set how the buttons looks and don't need to worry about the interation.
let up = UIButton()
let down = UIButton()
stepr.buttonAdd = up
stepr.buttonRemove = down
You can change current number (or index, if you're supplying a data array) programmatically.
stepr.currentNumber = 152
You can limit the current number.
// current number stays between 0 and 100
stepr.upperLimit = 100
stepr.lowerLimit = 0
Fits the value inside frame width of stepr. It works quite similar to UILabel.adjustsFontSizeToFitWidth.
stepr.adjustsFontSizeToFitWidth = true
Changes font of value.
stepr.font = UIFont.systemFontOfSize(64)
Changes text color.
stepr.textColor = UIColor.redColor()
You can supply your own data array into stepr. It will display string representation of these values instead of numbers.
// this will create a month stepper
stepr.dataArray = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
You can align buttons horizontally or vertically.
stepr.buttonAlignment = Stepr.ButtonAlignment.Horizontal
You can change easing and timing of animations. You can check anim for all available easing types.
stepr.easeDigitFadeIn = Stepr.Ease.CubicIn
stepr.easeDigitFadeOut = Stepr.Ease.BackInOut
stepr.easeDigitChangeEnter = Stepr.Ease.ExpoOut
stepr.easeDigitChangeLeave = Stepr.Ease.QuartInOut
stepr.easeDuration = 1
stepr.easeShowDelay = 1