UITabBarController中的tabBarItems的大小 [英] size of the tabBarItems in a UITabBarController

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

问题描述

我的APP中有4个iPad标签.问题是有时文本比按钮大,但我有更多的空间可以使用.但是,UITabBarController并没有使用tabBarItems的所有宽度.有选择吗?

I have 4 tabs in my APP for iPad. The problem is that sometimes the text is bigger than the button but i have more space to use. However, the UITabBarController doesn't use all the width for the tabBarItems. Is there an option to do it?

推荐答案

UITabBarController将在它们之间自动插入空格.你可以做两件事

UITabBarController will automatically insert spaces in between. You could do two things

  1. 重写UITabButton的sizeThatFits方法以赋予其自己的大小
  2. 在两者之间插入负宽度空格

对于选项2,这是我用于UINavigationBar工具栏的一些示例代码(并且也应适用于UITabBarController)

For option 2, here's some sample code I used for toolbars of UINavigationBar (and should be applicable to UITabBarController as well)

UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:self action:nil];
space.width = -10;

[self setToolbarItems:[[NSArray alloc] initWithObjects:tab_item1,space,tab_item2, nil] animated:NO];

我建议在左边使用一个空格,在右边使用一个空格,并在每个选项卡按钮之间使用一个空格.

I'd suggest to use one space item to the left, one space item to the right and a space item for between of each tab buttons.

这篇关于UITabBarController中的tabBarItems的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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