如何将图像添加到UIToolBar? [英] How to add image(s) to UIToolBar?

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

问题描述

我想向用户无法与之交互的UIToolBar添加图像.本质上,它只是一个非交互式指示器,如徽章.

I'd like to add an image to a UIToolBar that a user cannot interact with. It would essentially be just a non-interactive indicator, like a badge.

这可能吗? 如果可以,怎么办?

Is this possible? If so, how?

推荐答案

用图像创建UIBarButtonItem并将其添加..!?

Create an UIBarButtonItem with an image and add it..!?

示例:

UIBarButtonItem* item = [[UIBarButtonItem alloc] initWithImage: yourImage style: UIBarButtonItemStyleBordered target: nil action: nil];

如果您不希望按钮出现,请尝试使用:

If you don't want the button appeareance, try to use:

UIBarButtonItem* item = [UIBarButtonItem initWithCustomView: yourImageView];

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

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