Skip to content

Instantly share code, notes, and snippets.

@d-amend
Created June 2, 2014 09:15
Show Gist options
  • Save d-amend/37d20b423a3133b403c3 to your computer and use it in GitHub Desktop.
Save d-amend/37d20b423a3133b403c3 to your computer and use it in GitHub Desktop.
Animate alpha of an array of views step by step
/**
* The alpha is changed step by step in order of array
* @param duration the duration of the animations for each view
*/
- (void)animateAlphaForViews:(NSArray *)views to:(CGFloat)alpha duration:(CGFloat)duration
{
if (views.count > 0) {
UIView *view = views.firstObject;
NSMutableArray *newViews = [views mutableCopy];
[newViews removeObject:view];
[UIView animateWithDuration:duration
animations:^{
// alpha blending
[view setAlpha:alpha];
}
completion:^(BOOL finished) {
[self animateAlphaForViews:newViews to:alpha duration:duration];
}];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment