0
@IBAction func BtnClickMe(sender: UIButton) {
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(ViewController.CLOCK), userInfo: nil, repeats: true)
}
타이머가 실행 중일 때 시계 기능이 있습니다. 0 초에 도달하면 시계를 멈 춥니 다.시간이 끝나면 버튼을 자동으로 비활성화하는 방법
@objc func CLOCK(){
sec = sec - 1
lbnTime.text = "\(sec)"
if(sec == 0){
lbnTime.text = "Time Up"
timer.invalidate()
//disable button here
}
}
감사합니다! –
답변이 도움이 되었다면 수락 된 것으로 표시하십시오. – Kevinosaurio