Wun*_*Wun 14 image navigationbar ios
我正在开发IOS,我使用以下代码来设置背景navigationBar.
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"bar-back"] forBarMetrics:UIBarMetricsDefault];
我想在下图中添加一个图像navigationBar和中心navigationBar.

如何在Objective-C的navigationBar中心添加图像?
提前致谢.
Jag*_*een 34
设置导航标题视图如下所示 
self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"img.png"]];
UIImage *img = [UIImage imageNamed:@"1.png"];
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
[imgView setImage:img];
// setContent mode aspect fit
[imgView setContentMode:UIViewContentModeScaleAspectFit];
self.navigationItem.titleView = imgView;
正如你所说的那样为应用程序设置一个图标.您可能希望为此展示整个应用程序的图标.
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon"]];
CGSize imageSize = CGSizeMake(40, 40);
CGFloat marginX = (self.navigationController.navigationBar.frame.size.width / 2) - (imageSize.width / 2);
imageView.frame = CGRectMake(marginX, 0, imageSize.width, imageSize.height);
[self.navigationController.navigationBar addSubview:imageView];
输出:
