Reputation: 4997
I was using that piece of code to display a UIViewController as a modal with a translucent background (Working on IOS7 and lower).
MyViewController *myViewController = [[MyViewController alloc] init];
navController.modalPresentationStyle = UIModalPresentationCurrentContext;
[navController presentViewController:myViewController animated:NO completion:nil];
Now compiling with IOS8 show a modal with a black background.
Is there any solution ? (Without make an animated subView) Thanks.
Upvotes: 2
Views: 1159
Reputation: 2135
In iOS 8 and above, you can use 'UIModalPresentationOverCurrentContext' for this purpose. From the UIViewController documentation:
UIModalPresentationOverCurrentContext
A presentation style where the content is displayed over only the parent view controller’s content. The views beneath the presented content are not removed from the view hierarchy when the presentation finishes. So if the presented view controller does not fill the screen with opaque content, the underlying content shows through.
When presenting a view controller in a popover, this presentation style is supported only if the transition style is UIModalTransitionStyleCoverVertical. Attempting to use a different transition style triggers an exception. However, you may use other transition styles (except the partial curl transition) if the parent view controller is not in a popover.
Available in iOS 8.0 and later.
I was not aware that see-through modally presented view controllers were ever supported prior to iOS 8 (and will be looking into that for my own use), but the above option definitely works in my testing in the new OS.
Note: Be sure to give your presented view controller a backgroundColor of clearColor.
Upvotes: 2