问题
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?
回答1:
UITabBarController will automatically insert spaces in between. You could do two things
- Override UITabButton's sizeThatFits method to give it your own size
- Insert negative-width spaces in between
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.
来源:https://stackoverflow.com/questions/15054056/size-of-the-tabbaritems-in-a-uitabbarcontroller