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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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)
}
Where customView is my UIView, you can create your UIImageView similarly.