Josh Kahane Josh Kahane - 1 year ago 126
Objective-C Question

Transparent ViewController to See Parent Below?

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.

Any help with achieving this would be much appreciated, thanks.

Answer Source

@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.


self.modalPresentationStyle = UIModalPresentationCurrentContext;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download