Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top