Skip to content

Instantly share code, notes, and snippets.

@psobko
Created October 6, 2014 23:05
Show Gist options
  • Save psobko/de4a42e3eb28ef7c0e42 to your computer and use it in GitHub Desktop.
Save psobko/de4a42e3eb28ef7c0e42 to your computer and use it in GitHub Desktop.
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