UIView默认样式有圆角吗? [英] UIView default styling has rounded corners?

查看:113
本文介绍了UIView默认样式有圆角吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 UIPopoverController 来显示 UIView 。布局有点类似于 UISplitViewController 所以看起来在细节视图上有圆角是非常奇怪的,因为它留下了一个小间隙。我还没有找到任何与其他有这个问题的人相关的东西,但这些圆角似乎是默认的样式。是否可以删除它们?

I am using a UIPopoverController to display a UIView. The layout is somewhat similar to a UISplitViewController so it is very strange looking to have rounded corners on the "detail view" because it leaves a small gap. I have not been able to find anything at all relating to other people having this problem, but these rounded corners seem to be the default style. Is it possible to remove them?

可能有所帮助的事情:


  • I从nib文件加载我的视图,但我目前没有更改默认 UIView

  • 我尝试设置 clipsToBound = NO in viewDidLoad

  • 我尝试设置 layer.cornerRadius = 0 in viewDidLoad

  • I load my view from a nib file, but I have currently made no changes to the default UIView
  • I tried setting clipsToBound = NO in viewDidLoad
  • I tried setting layer.cornerRadius = 0 in viewDidLoad

似乎也有成为视图顶部的阴影,但很难说。有什么方法可以摆脱所有这些默认样式?我只想要一个空白方块。

There also seems to be a shadow on the top part of the view, but it is hard to tell. Is there any way I can just get rid of all this default styling? I just want a blank square.

推荐答案

没有支持的方法可以使UIPopoverController内部的视图没有圆角。 UIPopoverController的内部代码将视图添加到具有剪切到边界的圆角的视图。

There is no supported way to make the view inside of your UIPopoverController not have rounded corners. The internal code of the UIPopoverController adds your view to a view with rounded corners that clips to bounds.

可能有一种hackish方式,即等到UIPopoverController显示然后遍历视图的所有父级并将它们全部设置为 cornerRadius = 0; clipsToBounds = NO; ,但即使您找到了解决方案,它可能与所有iOS版本都不兼容,如果Apple将来更改了UIPopoverController的一些内部代码,那么您的解决方案可能会中断。

There may be a hackish way to do it, i.e. waiting until the UIPopoverController is shown and then traversing through all of the parent's of your view and setting them all to have cornerRadius = 0; and clipsToBounds = NO;, but even if you find a solution it might not be compatible with all versions of iOS and if Apple changes some internal code of UIPopoverController in the future then your solution could break.

如果您真的想要这样做,那么最好的方法是创建一个模仿UIPopoverController功能的类。

If you really want to do this then the best way to go is to create your own class that mimics the UIPopoverController functionality.

这篇关于UIView默认样式有圆角吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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