UITabBarController中tabBarItems的大小
我在iPad
有4个标签。 问题是,有时文本比button更大,但我有更多的空间来使用。 但是, UITabBarController
不使用tabBarItems
所有宽度。 有没有办法做到这一点?
UITabBarController将自动在两者之间插入空格。 你可以做两件事
- 重写UITabButton的sizeThatFits方法给它你自己的大小
- 在中间插入负宽度的空格
对于选项2,下面是我用于UINavigationBar工具栏的一些示例代码(也适用于UITabBarController)
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];
我build议在左边使用一个空格项,右边使用一个空格项,在每个选项卡button之间使用空格项。