Skip to content

Instantly share code, notes, and snippets.

@parachvte
Last active August 29, 2015 14:20
Show Gist options
  • Select an option

  • Save parachvte/23c765509063907772ff to your computer and use it in GitHub Desktop.

Select an option

Save parachvte/23c765509063907772ff to your computer and use it in GitHub Desktop.
iOS - Continuous Animations
@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