在导航条中添加图片,应该是贯穿整个应用的。怎么实现?
需要在所有的导航控制器中都添加。
谢谢
UIImage *image = [UIImage imageNamed: @"yourImageName.png"];
UIImageView *imgView = [[UIImageView alloc] initWithImage: image];
self.navigationItem.titleView = imgView;
UINavigationBar *navBar = self.navigationController.navigationBar;
UIImage *image = [UIImage imageNamed:@"image.png"];
[navBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
1.设置全局的UINavigationBar 的背景图片
[[UINavigationBar appearance] setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
2.针对个别导航条的背景图片设置
[self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];