带有不同初始化按钮的计数器

时间:2018-07-10 01:35:32

标签: button set counter

我没有问题,也没有抱怨我使用不同设置进行计数的方法!我使用的每个功能都代表一个按钮,因此,set1运行一个计数器60秒,set2运行一个计数器40秒。

因为我想使用更多按钮,请问有什么方法可以优化我的方法?

    @IBAction func set1(_ sender: Any) {
    if isTimerRunning == false {
        runTimer()  // this is the timer
        seconds = 60
        self.startButton.isEnabled = false
    }

}

    @IBAction func set2(_ sender: Any) {
    if isTimerRunning == false {
        runTimer()
        seconds = 40
        self.startButton.isEnabled = false
    }

}

0 个答案:

没有答案