I have 10 UILabels
, maybe some UIImageViews
. I want to display all these in 1 UIView
with smooth FadeOut & FadeIn transition, one after the other.
I know putting UIView
animations in a for-loop will not work as animations are done asynchronous & will not give proper effect. So the way normally I would do this is to chain UIView
animation together. i.e. after one elements animation is complete begin the next one. For 3-4 elements the code looks ok. Like so -
[UIView animateWithDuration:0.25
delay:0
options:UIViewAnimationCurveEaseInOut
animations:^{ //do something with alpha here - first element }
completion:^(BOOL finished){
[UIView animateWithDuration:0.25
delay:0
options:UIViewAnimationCurveEaseInOut
animations:^{ //do something with alpha here - 2nd element}
completion:^(BOOL finished){ ... }
}
But for 10+ elements it gets very messy. How would one go about doing this? Essentially I am creating a UIView
with looping content, much like a widget.