iOS:为什么我的模态视图上有白色圆角? [英] iOS: Why do I have white, rounded corners on my modal view?

查看:221
本文介绍了iOS:为什么我的模态视图上有白色圆角?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的iPad应用程序中出现了一个模态视图,由于某种原因,它有白色圆角。

I have a modal view popping up in my iPad app and for some reason it has white, rounded corners.

值得注意的是我建立了这个模型视图在我的故事板中,而不是以编程方式。但是,在我的viewWillAppear方法中,我设置了角半径,如此...

It might be worth noting I built this model view in my storyboard, not programmatically. However, in my viewWillAppear method, I'm setting the corner radius like so...

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.view.layer.cornerRadius = 6.0f;
}

当我将值设置为6以上时,白色角落变得可见。如果没有显示这些白色圆角,我怎样才能设置更高的值?

When I set the value above 6, the white corners become visible. How can I set the value higher without these white rounded corners showing?

非常感谢您的智慧!

推荐答案

您的问题对于您的视图控制器使用的是什么类型的演示文稿是模棱两可的,所以我假设您正在使用表单。解决方案是将superview的背景颜色设置为 [UIColor clearColor] 以防止出现半透明背景:

Your question is ambiguous about what kind of presentation you're using for your view controller, so I'm going to assume you're using a form sheet. The solution is to set the superview's background color to [UIColor clearColor] to prevent the translucent background from appearing:

- (void) viewDidAppear:animated
{
    [super viewDidAppear:animated];

    self.view.layer.cornerRadius = 10;
    self.view.layer.masksToBounds = YES;
    self.view.superview.backgroundColor = [UIColor clearColor];
}

在设置 backgroundColor 之前:

设置 backgroundColor 后:

这篇关于iOS:为什么我的模态视图上有白色圆角?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆