문제

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.

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top