我的布局如下:
LbShowTimeTicking
问题:如何显示时间正在滴答作响。
说我有标签LbShowTimeTicking显示:小时:10分钟:30秒:10
时间开始滴答,直到Hrs:0 Min:0,second:0
func setUpTimer(){
let date = Date()
let calendar = Calendar.current
let components = calendar.dateComponents([.day,.hour,.minute,.second], from: date as Date)
let currentDate = calendar.date(from: components)
let userCalendar = Calendar.current
var CountDownDate = DateComponents()
CountDownDate.year = 2017
CountDownDate.month = 11
CountDownDate.day = 10
CountDownDate.hour = 09
CountDownDate.minute = 10
let CountDownDay = userCalendar.date(from: CountDownDate as DateComponents)
let CountDayDiff = calendar.dateComponents([.day,.hour,.minute,.second], from: currentDate!, to: CountDownDay!)
let hoursLeft = CountDayDiff.hour
let minutesLeft = CountDayDiff.minute
let secondsLeft = CountDayDiff.second
DispatchQueue.main.async {
self.Vw_Panel.isHidden = false
self.lbShowTime.isHidden = false
self.lbShowTime.text = " Hrs: \(hoursLeft ?? 0),Min:\(minutesLeft ?? 0), Sec:\(secondsLeft ?? 0)"
}
}
请帮忙。
由于