-
-
Save faimin/e1704d1e19925dc4ed185b6637426229 to your computer and use it in GitHub Desktop.
Custom animation for modal dismiss
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
- (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