KWStepper 是使用 Swift 编写的计步器,跟 UIStepper 是不一样的,KWStepper 允许一个完全自定义的 UI,并且提供可选择的委托方法来定制用户的体验。
var stepper: KWStepper?@IBOutlet weak var countLabel: UILabel!@IBOutlet weak var decrementButton: UIButton!@IBOutlet weak var incrementButton: UIButton! self.stepper = KWStepper( decrementButton: self.decrementButton, incrementButton: self.incrementButton)if let stepper = self.stepper { stepper.addTarget(self, action: Selector("stepperDidChange"), forControlEvents: .ValueChanged) } func stepperDidChange() { self.countLabel.text = NSString(format: "%.f", self.stepper!.value) }