删除标签栏项目文本,仅显示图像 [英] Remove tab bar item text, show only image

查看:93
本文介绍了删除标签栏项目文本,仅显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简单的问题,我如何删除标签栏项目文字并仅显示图片?

我想要条形图项目在Instagram应用程序中:

I want the bar items to like in the instagram app:

在xcode 6的检查器中,我删除标题并选择@ 2x(50px)和@ 3x(75px)图像。但是,图像不使用已删除文本的可用空间。有任何想法如何在Instagram应用程序中实现相同的标签栏项目图像?

In the inspector in xcode 6 I remove the title and choose a @2x (50px) and a @3x (75px) image. However the image does not use the free space of the removed text. Any ideas how to achieve the same tab bar item image like in the instagram app?

推荐答案

你应该玩 imageInsets UITabBarItem 的属性。下面是示例代码:

You should play with imageInsets property of UITabBarItem. Here is sample code:

let tabBarItem = UITabBarItem(title: nil, image: UIImage(named: "more")
tabBarItem.imageInsets = UIEdgeInsets(top: 9, left: 0, bottom: -9, right: 0)

UIEdgeInsets 中的值取决于您的图片大小。以下是我的应用中该代码的结果:

Values inside UIEdgeInsets depend on your image size. Here is the result of that code in my app:

这篇关于删除标签栏项目文本,仅显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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