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.)
@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;
When you modally present a view controller the , it goes on the stack which in turn hides the view controller below it. So all you can do is to present a transparent view with animation similar to modally presenting a view controller.
Swift 3 -
Try vc.modalPresentationStyle = .overFullScreen
let vc = self.storyboard!.instantiateViewControllerWithIdentifier("ExampleViewController") as! ExampleViewController
vc.view.backgroundColor = UIColor.clearColor()
vc.modalPresentationStyle = .overFullScreen
self.presentViewController(vc, animated: true, completion: nil)