颜色navigationController

时间:2014-04-03 12:43:09

标签: ios objective-c colors uinavigationcontroller uinavigationbar

当我更改动态 {{1>}的颜色时,我遇到了问题。我希望得到我的navigationbar像第二个屏幕截图。

任何帮助将不胜感激:)

这是我的代码:

navigationbar

结果:

enter image description here

我想要的是什么:

enter image description here

5 个答案:

答案 0 :(得分:4)

试试吧......

      self.navigationController.navigationBar.backgroundColor=[UIColor colorWithRed:215.0f/255.0f green:215.0f/255.0f blue:215.0f/255.0f alpha:1.0f];

适用于iOS> 7

   self.navigationBar.barTintColor=[UIColor colorWithRed:215.0f/255.0f green:215.0f/255.0f blue:215.0f/255.0f alpha:1.0f];
   self.navigationBar.tintColor = [UIColor whiteColor];
   self.navigationBar.translucent = NO;

答案 1 :(得分:1)

[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"imgNavigationbar.png"] forBarMetrics:UIBarMetricsDefault];

答案 2 :(得分:0)

按如下所示更新您的代码并尝试:

 self.navigationController.navigationBar.backgroundColor = [UIColor colorWithRed:(76.0f/255.0) green:(170.0f/255.0) blue:(255.0f/255.0) alpha:1.0f];

答案 3 :(得分:0)

不用改变颜色,而是用图像替换它。

[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar.png"] forBarMetrics:UIBarMetricsDefault];

答案 4 :(得分:0)

- (void)customizeUserInterface
{
    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]];
    }
}