Swift 简单倒计时5s示例
2021-08-04 本文已影响0人
wenju
var countDownNum = 5
Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { timer in
if countDownNum == 0 {
//倒计时5s,销毁计时器
timer.invalidate()
} else {
countDownNum -= 1
}
}