xcode 如何删除 PopoverView 中的圆角?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22710213/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to remove rounded corners in PopoverView?
提问by Michael
I built a custom Popoverview, but fail to remove the content's rounded corners.
我构建了一个自定义的 Popoverview,但未能删除内容的圆角。
Tried to set .layer.cornerRadius = 0.0
in almost every view in found, with no success.
试图.layer.cornerRadius = 0.0
在发现的几乎所有视图中设置,但没有成功。
Image Link: Custom Popover
图片链接:自定义弹出框
Red border is of UIViewController used to init the UIPopoverController with, green is background of custom UIPopoverBackgroundView.
红色边框是用于初始化 UIPopoverController 的 UIViewController,绿色是自定义 UIPopoverBackgroundView 的背景。
回答by Lord Zsolt
Answer from this thread: UIView default styling has rounded corners?
来自该线程的回答:UIView 默认样式有圆角?
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.
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.
If you really want to do this then the best way to go is to create your own class that mimics the UIPopoverController functionality.
没有支持的方法可以使 UIPopoverController 内部的视图没有圆角。UIPopoverController 的内部代码将您的视图添加到带有圆角的视图中,该圆角可以裁剪到边界。
可能有一种骇人听闻的方法来做到这一点,即等待显示 UIPopoverController 然后遍历您视图的所有父视图并将它们全部设置为具有cornerRadius = 0; 和 clipsToBounds = NO;,但是即使您找到了解决方案,它也可能无法与所有版本的 iOS 兼容,并且如果 Apple 将来更改 UIPopoverController 的某些内部代码,那么您的解决方案可能会中断。
如果您真的想这样做,那么最好的方法是创建自己的类来模仿 UIPopoverController 功能。