[英]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.