Created
June 2, 2014 09:15
-
-
Save d-amend/37d20b423a3133b403c3 to your computer and use it in GitHub Desktop.
Animate alpha of an array of views step by step
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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