2013-09-25 229 views
-1

有谁知道,我如何才能使iOS7中的UINavigationBar全黑?默认它是白色的,我需要黑色。IOS7 UINavigationBar黑色背景

+0

可能复制[如何更改iOS 7中的导航栏颜色?](http://stackoverflow.com/questions/18929864/how-do-i-change-the-navigation-bar-color-in-ios-7 ) – Rajneesh071

回答

0

下面是编程创建了一个黑色的UIImage,并将其设置为UINavigationBar的外观的一种方式:

UIView *background = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 568, 44)]; 
background.backgroundColor = [UIColor blackColor]; 
UIGraphicsBeginImageContext(background.frame.size); 
CGContextRef context = UIGraphicsGetCurrentContext(); 
[background.layer renderInContext:context]; 
UIImage *backgroundImage = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext();   

[[UINavigationBar appearance] setBackgroundImage:backgroundImage 
              forBarMetrics:UIBarMetricsDefault]; 
0

找到了我自己。进入故事情节,设计师,选择视图控制器,请从属性推断督察,改变上栏“不透明的黑色导航栏”

+0

Interface-Builder不幸的只是提供了一个模拟的外观(查看标签,它说“Simulated Metrics”)。您需要在代码(每个ViewController)或您的info.plist(每个应用程序)中设置它。 – auco

1

如果你的目标只适用于iOS 7,您可以使用:

[[UINavigationBar appearance] setBarTintColor:(UIColor *)];