[英]How do I add UIImage to center of UINavigationBar?
我的问题是我的图像width = 44
, height = 44
。 此方法无法正常工作。
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"image_44.png"] forBarMetrics:UIBarMetricsDefault];
如何将UIImage
添加到UINavigationBar
中心?
试试这个:
UIImageView *titleView = [[UIImageView alloc] initWithImage:myUIImage];
[self.navigationItem setTitleView:titleView];
使用Swift:
var titleView = UIImageView(image: UIImage(named: "nameOfTheImage.ext"))
self.navigationItem.titleView = titleView
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.