我是编程的新手,所以请原谅任何缺乏清晰度.我正在尝试使用animateWithDuration方法使我的一个按钮具有"闪烁效果".目前,它作为"淡入淡出",按钮逐渐显示并每1秒消失(我将持续时间设置为1.0).我希望降低动画的速度(不是持续时间,而是速度),这样动画效果会突然发生.动画的间隔需要每1秒钟保持一次.这有可能实现吗?我一直在研究,似乎animateWithDuration不允许这种规范......我是否需要通过另一种方法来解决这个问题?我在下面包含我的代码.谢谢你的帮助!顺便说一句,这都是在UIKit的UIViewController下.
override func viewDidLoad() {
super.viewDidLoad()
self.tapButton.alpha = 0
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(true)
UIView.animateWithDuration(1.0, delay: 0, options: .Repeat | .AllowUserInteraction | .Autoreverse, animations: { () -> Void in self.tapButton.alpha = 1.0
}, completion: nil )
}
Run Code Online (Sandbox Code Playgroud)