Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Popup Present Model View
- (void)presentModalViewController:(UIViewController *)modalViewController fromView:(UIView *)view
{
if(SYSTEM_VERSION_LESS_THAN(@"6.0")) {
[modalViewController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentViewController:modalViewController animated:YES completion:nil];
} else {
modalViewController.modalPresentationStyle = UIModalPresentationFormSheet;
UIGraphicsBeginImageContext(self.view.window.frame.size);
[self.view.window.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[self.view.window setBackgroundColor:[UIColor colorWithPatternImage:viewImage]];
// Add the modal viewController but don't animate it. We will handle the animation manually
[self presentModalViewController:modalViewController animated:NO];
[modalViewController.view setTransform:CGAffineTransformMakeScale(0, 0)];
[UIView animateWithDuration:0.3f animations:^{
[modalViewController.view setTransform:CGAffineTransformMakeScale(1, 1)];
}];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment