[英]Show transparent background for modal view
我想通过导航控制器显示模式视图,并且该视图的背景应该是透明的。 在模态视图控制器中,我清除了viewDidLoad的背景,如下所示:
self.view.backgroundColor = [UIColor clearColor];
我显示此视图如下:
ModalViewController *modalViewController = [[ModalViewController alloc] init];
[self.navigationController presentViewController:modalViewController animated:YES completion:nil];
结果显示了我的视图,但背景为黑色。 我试着做:
[self setModalPresentationStyle:UIModalPresentationCurrentContext];
对于我所有的视图控制器,都包括NavigationController。 我试着做:
self.navigationController.providesPresentationContextTransitionStyle = YES;
self.navigationController.definesPresentationContext = YES;
但是,所有这些都不起作用。 有可能执行我的任务,还是应该以其他方式显示我的观点?
您是否通过UIViewController在SO Display clearColor UIViewController上检查了这个问题?
它似乎可以回答您的问题。 基本上,您必须将表示样式设置为“ UIModalPresentationCurrentContext”。
我使用UIModalPresentationCurrentContext代替了UIModalPresentationOverCurrentContext。 使用UIModalPresentationOverCurrentContext解决了此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.