我的导航栏自定义UIColor

时间:2014-04-03 21:52:23

标签: xcode5 uinavigationbar uicolor ios7.1 uistatusbar

我正在尝试将导航栏和状态栏设置为“color5”

UIColor* color5 = [UIColor colorWithRed: 0.114 green: 0.705 blue: 1 alpha: 1];

我将导航栏设为属性并尝试设置色调颜色:

navBar.tintColor = color5;

但这不起作用。 我也试过在AppDelegate中做到这一点:

[[UINavigationBar appearance] setBarTintColor:UIColorFromRGB(0x067AB5)];

这有效,但未将导航栏设置为我想要的颜色,只设置导航栏,而不是状态栏。我试图找出我的UIColor的十六进制数,但我无法弄明白。我认为问题是它有小数,但它可以很好地设置我正在使用的按钮。 非常感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

您可以使用此

if (IOS_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"))
    {
        [[UINavigationBar appearance] setBarTintColor:[UIColor whiteColor]];
    } else
    {
        [[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
        [[UINavigationBar appearance] setBackgroundColor:[UIColor whiteColor]];
    }