How to set UISwitch border color?

k06a picture k06a · Feb 22, 2014 · Viewed 10k times · Source

My app has:

[[UIView appearance] setTintColor:[UIColor whiteColor]];

And here is what I have when on:

switch in on position

and off:

switch in off position

I need to make UISwitch border visible like in Settings.app:

Settings app

Answer

sangony picture sangony · Feb 22, 2014

Your [[UIView appearance] setTintColor:[UIColor whiteColor]]; is interfering with the tint color of your switch. The command to set the tint color is self.mySwitch.tintColor = [UIColor grayColor]; which sets the color used to tint the outline of the switch when it is turned off.