我可以用下面的代码更改UISwitch的颜色,但颜色总是黄色的,如何将颜色更改为另一种颜色?
UISwitch *switch1=[[UISwitch alloc]initWithFrame:CGRectMake(70, 121, 94, 27)];
[switch1 setAlternateColors:YES];发布于 2011-12-10 18:45:37
最后,使用iOS5,您可以使用属性onTintColor更改开关的颜色。
UISwitch *s = [[UISwitch alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
s.on = YES;
s.onTintColor = [UIColor redColor];
[self.view addSubview:s];
[s release];制作这个

我希望这能有所帮助!
发布于 2010-10-11 02:14:06
检查带有自定义开关的项目的this page。
发布于 2010-10-10 22:53:37
在UISwitch reference中,“UISwitch类是不可定制的”。所以你不能改变UISwitch的外观。
https://stackoverflow.com/questions/3900737
复制相似问题