Swift - 连续背景动画循环 [英] Swift - Continuous background animation loop
问题描述
有人可以指出我如何制作 UIimageviews alpha 属性的无限循环动画的方向.从 0 - 1、1 - 0 开始.我对 iOS 和编程还很陌生,所以这可能听起来很愚蠢.如果不将整个应用程序置于无限循环中,我将如何实现这一点.
Can someone point me in the direction of how i'd go about making a endless loop animation of a UIimageviews alpha property. From the 0 - 1, 1 - 0. I'm fairly new to iOS and programming in general so this may sound dumb. How would I accomplish this without putting the entire app in an endless loop.
推荐答案
连续动画 我不认为这是移动应用程序中的好做法,也许我自己错了.无论如何,您可以尝试以下操作
Continuous animation I don't think this is a good practice in mobile applications, maybe myself wrong. Anyways you can try something like below
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
self.customView.backgroundColor = UIColor(red: 0.0, green: 255.0 , blue: 255.0, alpha: 1.0)
dispatch_async(dispatch_get_main_queue(), {
self.performAnimation()
})
}
func performAnimation() {
UIView.animateWithDuration(2.0, delay: 0.5, options: .CurveEaseOut | .Repeat | .Autoreverse, animations: {
self.customView.alpha = 0.0
}, completion: nil)
}
customView 是我的 UIView,您可以类似地创建您的 UIImageView.
Where customView is my UIView, you can create your UIImageView similarly.
这篇关于Swift - 连续背景动画循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!