我想更改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