iOS 7.1 Default tint color does not change for UISwitch

Majky picture Majky · May 2, 2014 · Viewed 8.9k times · Source

I've set default tint color in my storyboard, but I'm getting old blue, default color for my UISwitch component.

So I've tried to put

[[UIView appearance] setTintColor:APPCOLOR];

inside of my app delegate method

- (void)applicationWillResignActive:(UIApplication *)application

but still no luck, I also tried to put there

[[UISwitch appearance] setTintColor:APPCOLOR];

and again no change.

The APPCOLOR is defined in my constants.h file which I of course include.

How I can set this tint color of my UISwitch globally?

The tint color of other elements, for example UIButton changes properly.

Answer

Leo Natan picture Leo Natan · May 2, 2014

The UISwitch tint color controls the border color. If you want to set the on color, you need to use onTintColor.

Read here the documentation of what these tint colors represent for UISwitch.

enter image description here

Also, you should not be setting appearance in applicationWillResignActive: delegate method. This is called when the application resigns active state. You should set appearance in application:didLaunchWithOptions:.