Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 7.1 Default tint color does not change for UISwitch

Tags:

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.

like image 416
Majky Avatar asked May 02 '14 12:05

Majky


1 Answers

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:.

like image 151
Léo Natan Avatar answered Sep 19 '22 12:09

Léo Natan