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.
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.
#1 Open the ViewController This would open the ViewController without any fancy animations, but we want moooore. So, to make the UI popover transparent, we need to set the modalPresentationStyle to . overFullScreen . And to avoid the blurry background swiping in from the bottom, we set the modalTransitionStyle to .
@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;
I have been searching for the solution. Now thanks to iOS 8. They has introduced couple of new modalPresentationStyle. one among them is UIModalPresentationOverCurrentContext. Used the same to solve the this issue.
viewcontroller.modalPresentationStyle = UIModalPresentationOverCurrentContext;
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With