【发布时间】:2013-07-09 11:23:01
【问题描述】:
我想更改导航栏的背景图片(或颜色),但由于某种原因它不起作用。
我四处搜索,发现在 iOS 5.0+(我运行的是 6.1)上应该可以:
[self.navigationController.navigationBar setBackgroundImage:navigationBackgroundImage forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setBackgroundColor:[UIColor redColor]];
现在这些都不起作用。也尝试过:
self.navigationController.navigationBar.backgroundColor = [UIColor redColor];
现在我认为我将它分配给了错误的对象,但这有效:
UIImageView *titleImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"scr1_title"]];
self.navigationItem.titleView = titleImage;
【问题讨论】:
-
一个小问题,你是
UINavigationController的用户吗?
标签: ios image background uinavigationbar