如何将UIImage添加到UINavigationBar的中心? [英] How do I add UIImage to center of UINavigationBar?

查看:74
本文介绍了如何将UIImage添加到UINavigationBar的中心?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是我的图像 width = 44 height = 44 。此方法无法正常工作。

My problem is that I have an image with width = 44 and height = 44. This method didn't work properly.

[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"image_44.png"] forBarMetrics:UIBarMetricsDefault]; 

如何将 UIImage 添加到中心一个 UINavigationBar

How do I add an UIImage to center of an UINavigationBar?

推荐答案

试试这个:

UIImageView *titleView = [[UIImageView alloc] initWithImage:myUIImage];
[self.navigationItem setTitleView:titleView];

这篇关于如何将UIImage添加到UINavigationBar的中心?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆