ios - UIAppearence 只适用于 iOS 中的系统颜色?

标签 ios uinavigationbar uiappearance

我正在尝试使用 UIAppearance 更改应用程序中导航栏的颜色。

但只有当我使用系统颜色时,它才有效:

    UINavigationBar *navigationBarAppearance = [UINavigationBar appearance];

    [navigationBarAppearance setBarTintColor:[[UIColor alloc] initWithRed:220.0f green:47.0f blue:40.0f alpha:100.0f]]; // does not work

    [navigationBarAppearance setBarTintColor:[UIColor colorWithRed:220.0f green:47.0f blue:40.0f alpha:100.0f]]; // does not work

    [navigationBarAppearance setBarTintColor:[UIColor redColor]]; // works

有什么建议吗?

最佳答案

方法

colorWithRed:green:blue:alpha:

接受0.01.0之间的四个值。因此,如果您拥有从 0.0255.0 的分量,则需要除以 255.0f 进行标准化。

[UIColor alloc] initWithRed:220.0f/255.0f green:47.0f/255.0f blue:40.0f/255.0f alpha:100.0f/255.0f]

关于ios - UIAppearence 只适用于 iOS 中的系统颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24679041/

相关文章:

google-maps - 更改 UISearchBar textColor 不起作用

ios - MFMessageComposeViewController 外观 iOS 7

ios - 随机化声音的最简单方法是什么

ios - TestFlight 自动创建新版本

ios - 在导航栏按钮中显示未读消息的数量

ios - 透明的 UINavigationBar,但模糊

objective-c - 将时间以微秒为单位转换为分钟和秒

ios - 如何比较 NSDictionary 和 String 的值

objective-c - iPad 应用程序中的垂直 UINavigationBar

ios - UIAppearance 是否在 AppDelegate 之外工作?