【问题标题】:Show transparent background for modal view为模态视图显示透明背景
【发布时间】:2015-05-24 15:42:06
【问题描述】:

我想通过我的导航控制器显示一个模态视图,并且这个视图的背景应该是透明的。在模态视图控制器中,我清除 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;

然而,这一切都行不通。是否有可能实现我的任务,或者我应该用另一种方式展示我的观点?

【问题讨论】:

    标签: ios objective-c background uinavigationcontroller


    【解决方案1】:

    您是否在 SO Display clearColor UIViewController over UIViewController 上查看过这个问题?

    你的问题似乎有了答案。基本上你必须设置 表示样式为“UIModalPresentationCurrentContext”。

    【讨论】:

    • 感谢您的回答。我仔细写了你的链接,并在那里发现了我的问题:)
    【解决方案2】:

    我使用 UIModalPresentationCurrentContext 而不是 UIModalPresentationOverCurrentContext。使用 UIModalPresentationOverCurrentContext 解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-08-16
      • 1970-01-01
      • 2011-02-24
      • 1970-01-01
      • 1970-01-01
      • 2013-03-30
      • 2017-10-07
      相关资源
      最近更新 更多