Search code examples
iosswiftinterface-builderuipagecontrol

UIPageControl has unspecified grey background colour


I have a UIPageControl on a UIViewController however despite trying to change the background colour in the attributes inspector it remains this dark grey colour that does not display in the interface builder.

As shown in the image below:

Screenshot showing comparison between the simulator and interface builder.

Any ideas on how I can fix this? - ideally I want a transparent background but I just applied the yellow to compare more clearly.


Solution

  • Changing the background color of the UIPageControl can be done through the UIAppearance protocol.

    Apple Docs

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

    Example

    UIPageControl.appearance().backgroundColor = .darkGray
    

    Solution

    Make sure you do not have a call to change that.