我正在使用新的 UIAppearance API,并通过我的 AppDelegate 成功地为所有 UINavigationBar 和 UIToolbar 实例设置了色调颜色,就像这样...
- (void)customizeAppearance
{
UIColor *tint = [UIColor colorWithRed:212 green:63 blue:69 alpha:1.0];
[[UINavigationBar appearance] setTintColor:tint];
[[UIToolbar appearance] setTintColor:tint];
}
但是,如果我更改 RGB 值并重新构建/运行,工具栏和导航条都会变成白色,无论我将其设置为什么颜色!
就好像代理缓存在某处。当我删除应用程序然后重新安装时,RGB 值会按应有的方式显示,直到我更改它们并再次重建。
有没有人遇到过这种情况?我做错了什么吗?
更新 1:
现在,我注意到,它会在编译期间任意切换到白色背景,甚至不会更改 RGB。 (注意:上面的 RGB 应该返回淡红色调。)
更新 2:
我亲爱的未婚妻碰巧从我身后看着,注意到在我的测试用例中,问题似乎只在我同时在多个 RGB channel 中有值时才会出现。
例如:
UIColor *tint = [UIColor colorWithRed:212 green:0 blue:0 alpha:1.0];
工作了,而
UIColor *tint = [UIColor colorWithRed:212 green:63 blue:69 alpha:1.0];
不会。
解决方案?
改用colorWithHue:saturation:brightness:alpha:
。
最佳答案
问题是 [UIColor colorWithRed: green: blue: alpha:]
需要一组从 0.0f
到 1.0f
的 float .您正在传递一组整数。
关于iphone - UIAppearance 代理缓存编译时间之间的外观?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9765656/