Prior to iOS 7, according to this popular Stackoverflow question, the way to show a ViewController with a clear background was to do the following in the main ViewController:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"SecondViewController"];
vc.view.backgroundColor = [UIColor clearColor];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:vc animated:NO completion:nil];
However, as I have recently discovered with iOS 7 (and as commented by others to the main answer), the above solution no longer works, and instead just shows a black model controller. I know that transparency is largely used in iOS 7, so that transparent view controller is very likely possible. I haven't discovered a workaround to this issue yet, and was wondering if anyone knows how to resolve this problem. Thanks!
I just followed the original solution and applied some default and custom settings in Interface Builder, and seems to me it is working.
Important section (quite similar to the question's code):
- (IBAction)click:(id)sender {
NSLog(@"click");
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"TopOverVc"];
vc.view.backgroundColor = [UIColor clearColor];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:vc animated:NO completion:nil];
}
Also pls find the IB snaphot:
And the simulator result (after pressing button):
Hope I did not misunderstand sthing in your question ;) Happy coding!
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