Created
October 6, 2014 23:05
-
-
Save psobko/de4a42e3eb28ef7c0e42 to your computer and use it in GitHub Desktop.
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
NSMutableArray* animationBlocks = [NSMutableArray new]; | |
typedef void(^animationBlock)(BOOL); | |
animationBlock (^getNextAnimation)() = ^{ | |
animationBlock block = animationBlocks.count ? (animationBlock)animationBlocks[0] : nil; | |
if (block) | |
{ | |
[animationBlocks removeObjectAtIndex:0]; | |
return block; | |
} | |
else | |
{ | |
return ^(BOOL finished){}; | |
} | |
}; | |
[animationBlocks addObject:^(BOOL finished){ | |
[UIView animateWithDuration:0.5 | |
animations:^{ | |
//Animate stuff | |
} | |
completion: getNextAnimation()]; | |
}]; | |
//Start the chain | |
getNextAnimation()(YES); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment