Skip to content

Instantly share code, notes, and snippets.

@iamphill
Created April 8, 2013 16:06
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 iamphill/5338003 to your computer and use it in GitHub Desktop.
Save iamphill/5338003 to your computer and use it in GitHub Desktop.
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