如何完全着色UIPopoverPresentationController背景颜色?

时间:2021-02-08 00:05:30

I'm working with a Day and Night Mode for an app. The problem is, when just setting the background color of a view AND THEN using it as "presenting as popover" there are little white artifacts (see the picture)

我正在使用白天和黑夜模式的应用程序。问题是,当只是设置视图的背景颜色然后使用它作为“呈现为弹出”时,几乎没有白色文物(见图)

Is there an easy way to fix this? Do I may have to write my own UIView?

有没有一种简单的方法来解决这个问题?我可能要写自己的UIView吗?

如何完全着色UIPopoverPresentationController背景颜色?

2 个解决方案

#1


15  

You can set the UIPopoverPresentationController's backgroundColor. If that isn't sufficient, you will have to customize your popover's UIPopoverBackgroundView. This gives you control of the entire popover background, including the little triangle.

您可以设置UIPopoverPresentationController的backgroundColor。如果这还不够,则必须自定义popover的UIPopoverBackgroundView。这使您可以控制整个弹出窗口背景,包括小三角形。

#2


2  

Here is some code to supplement matt's answer.

这里有一些代码来补充matt的答案。

popoverController.popoverPresentationController?.backgroundColor = myColor

or

self.navigationController?.popoverPresentationController?.backgroundColor = myColor

#1


15  

You can set the UIPopoverPresentationController's backgroundColor. If that isn't sufficient, you will have to customize your popover's UIPopoverBackgroundView. This gives you control of the entire popover background, including the little triangle.

您可以设置UIPopoverPresentationController的backgroundColor。如果这还不够,则必须自定义popover的UIPopoverBackgroundView。这使您可以控制整个弹出窗口背景,包括小三角形。

#2


2  

Here is some code to supplement matt's answer.

这里有一些代码来补充matt的答案。

popoverController.popoverPresentationController?.backgroundColor = myColor

or

self.navigationController?.popoverPresentationController?.backgroundColor = myColor