我需要标签每5秒更改一次,例如 slideshow 我正在使用Swift 3
。
创建一个计时器,并在计时器调用的函数中进行所需的更改。var计时器:计时器!timer = timer.scheduledtimer(timeInterval:5.0,目标:self,selector:#selector(self.countdown),userInfo:nil,repots:recops:true);
var getLocationtimer:Timer = Timer()
self.getLocationtimer = Timer.scheduledTimer(timeInterval: 5, target:self, selector:#selector(YOUR_VIEW_CONTROLLER.updateLevel), userInfo:nil, repeats:true)
func updateLevel(){
//Update label your here
}
此计时器可以帮助您实现自己的目标。