Skip to content

Instantly share code, notes, and snippets.

@curthard89
Created November 27, 2011 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save curthard89/1397591 to your computer and use it in GitHub Desktop.
Save curthard89/1397591 to your computer and use it in GitHub Desktop.
void NSAnimationContextRunAnimationBlock( dispatch_block_t group, dispatch_block_t completionHandler, NSTimeInterval time )
{
[NSAnimationContext runAnimationBlock:group
completionHandler:completionHandler
duration:time];
}
+ (void)runAnimationBlock:(dispatch_block_t)group
completionHandler:(dispatch_block_t)completionHandler
duration:(NSTimeInterval)time
{
// run animation
[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:time];
group();
[NSAnimationContext endGrouping];
// block delay
dispatch_time_t popTime = dispatch_time( DISPATCH_TIME_NOW, (double)time * NSEC_PER_SEC);
dispatch_after( popTime, dispatch_get_main_queue(), completionHandler );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment