Background of the switch control is grey

Hey All,

For some reason, the background of my switch control is grey and I can’t figure out why. I’ve checked all the backgrounds of the views that are anywhere close to this control and they are all the same red color as you see in the image below.

What is causing the switch’s background to appear gray?

Thank you,
Jason

Hi @jfortyork,

How is this switch initialized? Is it created in the storyboard or programmatically?
Other thing that i would suggest is to check if there is usage of the UIAppearence class. Look for something like this:

UISwitch.appearance().backgroundColor = UIColor.gray

Hope this is helpful

Nikita

Thanks Nikita, I don’t initialize the switch in code at all. But I will try changing the background color using a similar statement to the right color. I’ll let you know what I find.

Just as a note, the background of that screen used to be dark gray, but then I changed it to red. So, I have a feeling there’s some view that has a gray background that’s causing this issue.

@jfortyork

Just in case, i would suggest you to make that view background to UIColor.clear, so you don’t have to change it’s background every time you change the color of the screen.

Nikita

Hi nikita, I had some code that was changing the background colour to gray. I missed it the first few times I was looking at my code. Thanks for responding!

This topic was automatically closed after 166 days. New replies are no longer allowed.