简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM