如何让标签自行更改并延迟 - 快速?

时间:2016-12-26 17:11:10

标签: swift xcode

我需要标签每隔5秒更改一次,如幻灯片我正在使用swift 3

2 个答案:

答案 0 :(得分:0)

创建一个Timer并在计时器调用的函数内进行所需的更改。 var timer:定时器! timer = Timer.scheduledTimer(timeInterval:5.0,target:self,selector:#selector(self.countDown),userInfo:nil,repeats:true);

答案 1 :(得分:0)

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
}

此计时器可以帮助您实现您的目标。