我已经在 Storyboard中设置了默认色调颜色,但我的 UISwitch 组件变成了旧蓝色,默认颜色。
所以我试着把
[[UIView appearance] setTintColor:APPCOLOR];
在我的应用委托(delegate)方法中
- (void)applicationWillResignActive:(UIApplication *)application
但是还是不行,我也试过放在那里
[[UISwitch appearance] setTintColor:APPCOLOR];
再次没有变化。
APPCOLOR
是在我的 constants.h 文件中定义的,我当然会包含该文件。
如何全局设置我的 UISwitch 的这种色调?
其他元素的色调,例如 UIButton 会正确更改。
最佳答案
UISwitch
色调控制边框颜色。如果要设置开启颜色,需要使用onTintColor
。
阅读here这些色调代表 UISwitch
的含义的文档。
此外,您不应在 applicationWillResignActive:
委托(delegate)方法中设置外观。当应用程序退出事件状态时调用。您应该在 application:didLaunchWithOptions:
中设置外观。
关于iOS 7.1 默认色调颜色不会为 UISwitch 更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23428003/