OGeek|极客世界-中国程序员成长平台

标题: ios - UIAppearence仅在iOS中使用系统颜色吗? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 10:47
标题: ios - UIAppearence仅在iOS中使用系统颜色吗?

我正在尝试使用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

有什么建议?



Best Answer-推荐答案


方法

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/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4