计时器在24小时内重置,以及如何在计时器swift上显示分钟和小时

时间:2015-11-02 21:35:41

标签: swift timer reset

我正在创建一个计时器应用程序,我希望计时器在24小时内重置自己。我现在也可以在几秒钟内完成计时器,并希望它在达到该时间段后更改为分钟和小时。我有一个开始按钮,不想添加停止按钮或重置按钮。这是我到目前为止的快速代码。

var timerCount = 0
var timerRunning = false
var timer = NSTimer()


@IBOutlet weak var timerLabel: UILabel!

func Counting(){

    timerCount += 1
    timerLabel.text = "\(timerCount)"

}

//Start button

@IBAction func startButton(sender: UIButton) {

    // If timer is not already running then start timer

    if timerRunning == false{
        timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("Counting"), userInfo: nil, repeats: true)

        timerRunning = true

    }

0 个答案:

没有答案