【发布时间】:2015-09-04 19:22:06
【问题描述】:
如果我想在计时器达到 0 时尽快添加一个函数。 有没有人有任何提示?这是我要实现它的代码。
class ViewController: UIViewController {
@IBOutlet weak var Counterlabel: UILabel!
var Nbr = 51
var timerValue = 52
var timer = NSTimer()
override func viewDidLoad() {
super.viewDidLoad()
let timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("Counter"), userInfo: nil, repeats: true)
}
@IBAction func Btn1(sender: AnyObject) {
Nbr = timerValue - 1
timerValue = timerValue - 1;
}
func Counter(){
Nbr -= 1
Counterlabel.text = "\(Nbr)"
}
}
【问题讨论】:
标签: ios swift function timer xcode6