我正在尝试使用 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.0
和1.0
之间的四个值。因此,如果您拥有从 0.0
到 255.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/