UIPageControl 具有未指定的灰色背景颜色

UIPageControl has unspecified grey background colour

我在 UIViewController 上有一个 UIPageControl,但是尽管尝试更改属性检查器中的背景颜色,它仍然是深灰色,不会在界面构建器中显示。

如下图所示:

关于如何解决这个问题的任何想法? - 理想情况下我想要一个透明的背景,但我只是应用了黄色来比较清楚。

确保设置 UIPageControltintColorcurrentPageIndicatorTintColor

可以通过 UIAppearance 协议更改 UIPageControl 的背景颜色。

Apple Docs

You can customize the appearance of instances of a class by sending appearance modification messages to the class’s appearance proxy.

例子

UIPageControl.appearance().backgroundColor = .darkGray

解决方案

确保您没有电话来更改它。