【发布时间】:2015-10-13 04:19:58
【问题描述】:
我是一个编程新手,我不知道如何在我的项目中触发我的函数。我只需要我的函数运行 4 秒,然后它就不必再次工作了。我不想要一个按钮来调用该功能,我希望它是自动的!谢谢!
PS。定时器变量是上面运行的定时器。
func fadeLabels() {
if timerCount > 3 {
timer.invalidate()
timerRunning = false
}
//Label Fade Functionality
if timerCount == 1 {
UIView.animateWithDuration(1.0, animations: { () -> Void in
self.countdownThree.alpha = 0
})
}
if timerCount == 2 {
UIView.animateWithDuration(1.0, animations: { () -> Void in
self.countdownTwo.alpha = 0
})
}
if timerCount == 3 {
UIView.animateWithDuration(1.0, animations: { () -> Void in
self.countdownOne.alpha = 0
})
}
}
感谢任何帮助我解决愚蠢问题的人!
【问题讨论】:
-
使用 switch 语句代替 if
-
我该怎么做?
-
查看页面了解更多关于开关的信息:developer.apple.com/library/prerelease/ios/documentation/Swift/…
标签: swift function timer triggers call