Skip to content

Instantly share code, notes, and snippets.

@emarashliev
Created February 25, 2014 16:29
Show Gist options
  • Save emarashliev/9212405 to your computer and use it in GitHub Desktop.
Save emarashliev/9212405 to your computer and use it in GitHub Desktop.
Custom animation for modal dismiss
- (void)dismiss
{
[CATransaction begin];
CATransition *transition = [CATransition animation];
transition.type = kCATransitionReveal;
transition.subtype = kCATransitionFromTop;
transition.duration = 0.25f;
transition.fillMode = kCAFillModeForwards;
transition.removedOnCompletion = YES;
[[UIApplication sharedApplication].keyWindow.layer addAnimation:transition forKey:@"transition"];
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
[CATransaction setCompletionBlock: ^ {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(transition.duration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^ {
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
});
}];
[self dismissViewControllerAnimated:NO completion:nil];
[CATransaction commit];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment