UISwitch's color
10,607
Solution 1
Finally, with iOS5 you can change the color of the switch with the property onTintColor
.
UISwitch *s = [[UISwitch alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
s.on = YES;
s.onTintColor = [UIColor redColor];
[self.view addSubview:s];
[s release];
produce this
I hope this help !
Solution 2
Check this page for a project with a custom switch.
Solution 3
From the UISwitch reference, "The UISwitch class is not customizable." So you can't change the appearance of UISwitch.
Author by
Admin
Updated on September 15, 2022Comments
-
Admin over 1 year
I can change UISwitch's color with below code but always color is yellow how to change color to another color?
UISwitch *switch1=[[UISwitch alloc]initWithFrame:CGRectMake(70, 121, 94, 27)]; [switch1 setAlternateColors:YES];
-
Denis Kozhukhov over 10 yearslook at Fry's answer.
-
taskinoor over 10 years@DenisKozhukhov, when this answer was made it was not possible. Please see the dates.