如何删除PopoverView中的圆角? [英] How to remove rounded corners in PopoverView?

查看:206
本文介绍了如何删除PopoverView中的圆角?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我构建了自定义的Popoverview,但是无法删除内容的圆角.

I built a custom Popoverview, but fail to remove the content's rounded corners.

试图在几乎所有找到的视图中设置.layer.cornerRadius = 0.0,但没有成功.

Tried to set .layer.cornerRadius = 0.0 in almost every view in found, with no success.

图片链接:自定义弹出框

红色边框是用于初始化UIPopoverController的UIViewController,绿色边框是自定义UIPopoverBackgroundView的背景.

Red border is of UIViewController used to init the UIPopoverController with, green is background of custom UIPopoverBackgroundView.

推荐答案

此线程的答案:

没有支持的方法来使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.

可能有一种怪异的方法,即等到显示UIPopoverController,然后遍历视图的所有父对象,并将它们全部设置为cornerRadius = 0;并且clipsToBounds = NO ;,但是即使您找到了解决方案,它也可能与所有版本的iOS不兼容,并且如果苹果将来更改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.

这篇关于如何删除PopoverView中的圆角?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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