UITabBarItem标题位置 [英] UITabBarItem title position

查看:136
本文介绍了UITabBarItem标题位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在网上搜索如何调整UITabBarItem标题位置的位置时,我跑过这个类似的帖子,仍然想知道如何做到这一点。

On searching the web on how to adjust the position of a UITabBarItem title position i ran over this similar post and still wondering how to do that.

甚至可以从标题位置调整一下自下而上? (例如5px)我需要这个,因为我有自定义图像,现在标题的位置并不完美。

Is it even possible to adjust the title position a bit from the bottom up? (for example 5px) I need this because i have custom images and now the position of the title is not perfect.

推荐答案

为什么你不是只为你的视图控制器有一个空的title属性,并将标题添加到选项卡的自定义图像?

Why don't you just have an empty title property for your view controller and add the title to your custom images for the tab?

你可以这样做(在iOS 5.0中) :

You can do this (in iOS 5.0):

UIImage* iconSelected = [UIImage imageNamed:@"tabIconSelected.png"];
UIImage* iconNotSelected = [UIImage imageNamed:@"tabIconNotSelected.png"];
UITabBarItem *updatesListItem = [[UITabBarItem alloc] initWithTitle:@"" image:iconSelected tag:0];
[updatesListItem setFinishedSelectedImage:iconSelected withFinishedUnselectedImage:iconNotSelected];
[navigationController setTabBarItem:updatesListItem];

其中 tabIconSelected.png tabIconNotSelected.png 都包含标签的标题文字。

where tabIconSelected.png and tabIconNotSelected.png both contain the title text for the tab.

我写了一篇简短的文章为您的UITabBar图标添加一些颜色,其中说明了如何使用带标签的自定义图像。

I have written a brief article "Add some colour to your UITabBar icons" which explains how to use custom images with tabs.

希望这会有所帮助。

这篇关于UITabBarItem标题位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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