Last active
August 29, 2015 14:20
-
-
Save parachvte/23c765509063907772ff to your computer and use it in GitHub Desktop.
iOS - Continuous Animations
This file contains hidden or 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
| @interface SomeClass | |
| typedef void (^AnimationBlock)(BOOL); | |
| @end | |
| // animationBlocks, where store all animation blocks | |
| NSMutableArray *animationBlocks = [NSMutableArray new]; | |
| AnimationBlock (^getNextAnimation)() = ^{ | |
| AnimationBlock block = animationBlocks.count ? [animationBlocks objectAtIndex:0] : Nil; | |
| if (block) { | |
| [animationBlocks removeObjectAtIndex:0]; | |
| return block; | |
| } else { | |
| return _completionCallback;// completion callback | |
| } | |
| }; | |
| // add callbacks | |
| [animationBlocks addObject:^(BOOL finished) { | |
| [UIView animateWithDuration:1.5f | |
| delay:0.0f | |
| options:UIViewAnimationOptionCurveEaseOut | |
| animations:^{ | |
| _artistImageView.alpha = 1.0f; | |
| } | |
| completion:getNextAnimation()]; | |
| }]; | |
| // start animations | |
| getNextAnimation()(YES); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment