2013-09-30 52 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的故事板內工作。