Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing onTintColor of UISwitch on iOS7?

Tags:

ios

ios7

uiswitch

Default onTintColor is green as I see it on iOS7 but I'd like it to be another color.

[myUISwitch setOnTintColor:[UIColor customColor]];

does not work. on/offImages have no effect on iOS7 as documentation says. Why could it be not working? How can I change its onTintColor?

like image 233
Mert Buran Avatar asked Nov 30 '22 02:11

Mert Buran


1 Answers

UISwitch *switch = [UISwitch alloc] init];
[switch setOnTintColor:[UIColor customColor]];
[myView addSubview:switch];

does not work. But

UISwitch *switch = [UISwitch alloc] init];
[myView addSubview:switch];
[switch setOnTintColor:[UIColor customColor]];

works. Tint color does not change unless it is visible. Someone to explain?

like image 120
Mert Buran Avatar answered Dec 06 '22 01:12

Mert Buran