2013-09-30 55 views
9

IOS7 navigatinBar tintColor改变我开发iPad应用。我正在用导航控制器在popover中打开一些屏幕。但我并没有改变navigationcontroller色调颜色IOS 7.我怎样才能改变这种颜色。感谢名单在酥料饼

enter image description here

UINavigationController *navigationController = [[[UINavigationController alloc] initWithRootViewController:airportsSearch] autorelease]; 
navigationController.navigationBar.barTintColor = [UIColor blackColor]; 
navigationController.navigationBar.translucent = NO; 
self.popOver=[[UIPopoverController alloc] initWithContentViewController:navigationController]; 

self.popOver.delegate     = self; 
[self.popOver setPopoverContentSize:CGSizeMake(285, 370)]; 

[self.popOver presentPopoverFromRect:tempButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES]; 
+0

http://stackoverflow.com/questions/18929864/how-do-i-change-the-navigation-bar-color-in-ios-7/18929980#18929980 – Rajneesh071

+0

@ Rajneesh071此方法不起作用: ( – hiwordls

+0

可以给我你的示例代码吗? – Rajneesh071

回答

35

这里的神奇的词,是barStyle,你需要做的,如果你需要它黑色的以下内容:

navigationController.navigationBar.barStyle = UIBarStyleBlack; 
navigationController.navigationBar.translucent = NO; 

如果你想改变它的颜色:

navigationController.navigationBar.barTintColor = [UIColor redColor]; 
navigationController.navigationBar.barStyle = UIBarStyleBlack; 
navigationController.navigationBar.translucent = NO; 
+0

雄伟,非常感谢你@null – hiwordls

+1

@null非常感谢你我有一个自定义的UINavigationController类,我在barStyle旁边设置了相同的属性。我所有的navigationControllers工作正常,他们在故事板中设置了UIBarStyleDefault,只有我的NavigationBars里面的Popovers是半透明的,barTintColor没有改变任何东西,只有tintColor设置好了,但是一旦我设置barStyle为Black,解决! –

+0

由于某种原因,将barStyle设置为UIBarStyleBlack会将th e导航栏阴影...可能是你有一个建议如何解决这个问题? –

6

设置NavigationBarStyle到UIBarStyleBlack也为我工作,但只通过故事板。

我在didFinishLaunchingWithOptions的AppDelegate方法试图

[[UINavigationBar appearance] setBarStyle:UIBarStyleBlack]; 

以及

[[UINavigationBar appearanceWhenContainedIn:[UIPopoverController class], nil] setBarStyle:UIBarStyleBlack]; 

。但没有任何改变。只有改变NavigationControllers导航栏的BarStyle的故事板内工作。