Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITabBarController tabBar setItemWidth doesn't work

I have six tabs and need to show them all without More button.jomafer answer says that setItemWidth does that. I called this in AppDelegate but it didn't work.

[[UITabBar appearance] setItemWidth:self.window.frame.size.width/6];  

I then called the above in TabBarController viewDidLoad but it still didn't work.
Even tried

[self.tabBar setItemWidth:self.window.frame.size.width/6]; 

But there are few like this which say that what I want is not possible using UITabBar. Is this true?

like image 632
Nitish Avatar asked May 12 '15 13:05

Nitish


1 Answers

UITabBar does not support more than 5 items without the "more" button.

Do you really need 6 buttons at the bottom of the screen? They're going to be small targets. Consider rethinking your workflow if you have 6 buttons you'll need to constantly access.

If you definitely need 6, just subclass UITabBar - I'm pretty sure you just need to override layoutSubviews and change a 5 to a 6 somewhere.

There's also an existing UITabBar replacement project called Infinite Tab Bar that might fit your needs, if you don't necessarily need all 6 buttons visible at all times.

like image 198
Ari Lotter Avatar answered Oct 19 '22 18:10

Ari Lotter