我想更改UINvaigationBar的背景顏色,並使用tintColor屬性,但不會更改顏色。您可以結帳下面的代碼。更改UINavigationBar的背景顏色
在我的AppDelegate我創造的UITabBarController
tabbar = [[UITabBarController alloc] init];
然後,我創建一個UINavigationController和我的UITableViewController重視它
UINavigationController *myNavigation = [[UINavigationController alloc] initWithRootViewController:myViewController];
然後附UINavigationControllers我的TabBar這樣
[tabbar setViewControllers:viewControllers]; //viewControllers is an array of UINavigationControllers
我試着設置屬性tintColor in myAppdelegate這樣
[[myNavigation navigationBar] setTintColor:[UIColor redColor]];
但如預期並沒有工作,所以我嘗試同樣在我的ViewController
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController.navigationBar setTintColor:[UIColor blackColor]];
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
self.navigationItem.title = @"Test";
}
而且還是沒有任何反應。請檢查下面的圖片,看看現在導航欄的外觀。
感謝你的幫助。
乾杯 罐子
那麼這聽起來很奇怪..對我來說[self.navigationController.navigationBar setTintColor:[UIColor blackColor]];這條線很酷.. – 2012-03-31 11:39:19
Upvoted你的問題,所以有人會注意到它::-)) – 2012-03-31 11:39:42
是啊..怪異和奇怪!我試着設置titleView self.navigationItem.titleView = viewForTitle;這是有效的。所以我想引用正確的UINvaigationController對象。 – Jugs 2012-03-31 11:45:43