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 Answer
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.
2 Comments
DanZimm
I want to re-enforce that a constant animation is probably not good practice (especially if this is a utility app of sorts). We want our non-game apps to conserve battery as best as possible. +1
Suresh Kumar Durairaj
Well, My sort would be the same. Even-though the business logic requires this type of utilities handle with care. +1