Mert Buran
Mert Buran

Reputation: 3017

Changing onTintColor of UISwitch on iOS7?

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?

Upvotes: 4

Views: 4546

Answers (1)

Mert Buran
Mert Buran

Reputation: 3017

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?

Upvotes: 20

Related Questions