iphone - UIAppearance 代理缓存编译时间之间的外观?

标签 iphone ios cocoa-touch ios5 uikit

我正在使用新的 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.0f1.0f 的 float .您正在传递一组整数。

关于iphone - UIAppearance 代理缓存编译时间之间的外观?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9765656/

相关文章:

ios - 使用 CAGradientLayer 类更改 UiView IOS 的渐变背景层颜色

ios - iOS7 中一致的后台获取?

ios - 使用自动调整大小的阿拉伯语英语 iPhone 用户界面?

iphone - 如何跨 View Controller 共享 UIView 和其他元素?

ios - UIButton 上的 AddTarget 未触发

ios - 每 x 秒更新一次带有速度的标签

iphone - 根据特定本地化动态切换 XIB

iPhone 设备字体

iphone - 应用程序在后台运行时如何获取当前位置

ios - userNotificationCenter didReceive 响应包含空通知(watchOS)