Transparent ViewController to See Parent Below?

Josh Kahane picture Josh Kahane · Dec 2, 2012 · Viewed 19.4k times · Source

I would like to modally add a view controller with a transparent background, so the parent view controller beneath can be seen. (This is in an app for iPhone, not for iPad.)

I have tried this:

TextFieldViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"TextFieldVC"];
vc.modalPresentationStyle = UIModalPresentationCurrentContext;
vc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self.navigationController presentViewController:vc animated:YES completion:^{}];

Without luck and given the view controller a clear color background. My view controller is in a storyboard if that changes anything.

Answer

or azran picture or azran · Dec 2, 2012

@Josh Kahane set the view controller that will present the transparent view controller with this code at the -ViewDidLoad and be sure to set the alpha channel of the UIViewController View to be lower then 1.

Code:

self.modalPresentationStyle = UIModalPresentationCurrentContext;