gpt4 book ai didi

iphone - UISwitch 的颜色

转载 作者:行者123 更新时间:2023-12-03 18:48:41 29 4
gpt4 key购买 nike

我可以使用下面的代码更改 UISwitch 的颜色,但颜色始终为黄色,如何将颜色更改为另一种颜色?

UISwitch *switch1=[[UISwitch alloc]initWithFrame:CGRectMake(70, 121, 94, 27)];
[switch1 setAlternateColors:YES];

最佳答案

最后,在 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];

制作这个

enter image description here

我希望这有帮助!

关于iphone - UISwitch 的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3900737/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com