SnappingStepper是用Swift写成的一个UIStepper的优雅的替代品,有拇指滑块,可更加灵活地控制数值更新。
使用示例:
let stepper = SnappingStepper(frame: CGRectMake(0, 0, 100, 40))override func viewDidLoad() { super.viewDidLoad() // Configure the stepper like any other UIStepper. For example: // // stepper.continuous = true // stepper.autorepeat = true // stepper.wraps = false // stepper.minimumValue = 0 // stepper.maximumValue = 100 // stepper.stepValue = 1 stepper.font = UIFont(name: "TrebuchetMS-Bold", size: 20) stepper.fontColor = UIColor.blackColor() stepper.backgroundColor = UIColor.redColor() stepper.thumbColor = UIColor.orangeColor() stepper.addTarget(self, action: "valueChanged:", forControlEvents: .ValueChanged) // If you don't want using the traditional `addTarget:action:` pattern you can use // the `valueChangedBlock` // snappingStepper.valueChangeBlock = { (value: Double) in // println("value: \(value)") // } view.addSubview(stepper)}func valueChanged(sender: AnyObject) { // Retrieve the value: stepper.value}
评论