2013-10-04 26 views
27

有沒有什麼辦法可以使iOS 7的目標爲UINavigationBar爲純色而沒有半透明性?我曾嘗試設置backgroundColor,barTintColor,不透明,透明/半透明等等,但沒有任何效果。如何在iOS 7上獲取不透明的UINavigationBar

任何人都知道如何做到這一點?

下面是我一直在使用的一些代碼塊。請注意我在navigationBar上設置的屬性。他們都沒有以任何順序或組合工作過。

@property (strong, nonatomic) UITabBarController *tabBarController; 

testViewController = [[TestViewController alloc] init]; 
anotherViewController = [[AnotherViewController alloc] init]; 
navigationController = [[UINavigationController alloc] 
          initWithRootViewController:testViewController]; 

navigationController.navigationBar.barTintColor = [UIColor darkGrayColor; 
navigationController.navigationBar.barStyle = UIBarStyleBlack; 
navigationController.navigationBar.translucent = YES; 
navigationController.navigationBar.opaque = YES; 

NSArray *tabBarViewControllers = [NSArray arrayWithObjects: 
             navigationController, 
             anotherViewController, nil]; 
self.tabBarController.viewControllers = tabBarViewControllers; 
+0

後的代碼。 – null

+0

請檢查編輯。謝謝。 – tentmaking

+3

嘗試在'testViewController'中放置'self.navigationController.navigationBar.translucent = NO;'。 – null

回答

53

你的代碼清單navigationController.navigationBar.translucent = YES;

將其設置爲否。

8

要使它完全不透明ü可以從屬性部分本身改變導航欄的風格!

Just set the style as Black!

這是怎麼看起來像當u使黑色

+0

我會嘗試將它翻譯成代碼。我沒有使用xib的。謝謝。 – tentmaking

+0

這似乎沒有工作。當我將barStyle設置爲UIBarStyleBlack時,我的UITableView項目仍然通過UINavigationBar顯示。 – tentmaking

+0

然後嘗試刪除半透明 –

7

爲了讓所有的導航欄不透明的,你可以只添加你如何設置半透明UINavigationBar.appearance().translucent = falseapplication:didFinishLaunchingWithOptions:

0
self.navigationController.navigationBar.isTranslucent = false 
相關問題