Skip to content

Instantly share code, notes, and snippets.

@stuartjmoore
Created October 11, 2011 22:49
Show Gist options
  • Save stuartjmoore/1279713 to your computer and use it in GitHub Desktop.
Save stuartjmoore/1279713 to your computer and use it in GitHub Desktop.
A way to show a transparent modal view controller. It's not really transparent, the modal just uses a screenshot as its background.
- (void)showCard:(id)sender
{
UIGraphicsBeginImageContext(self.view.window.frame.size);
[self.view.window.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIViewControllerSubclass *card = [[UIViewControllerSubclass alloc] init];
card.background = screenshot;
[self presentModalViewController:card animated:NO];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment