I have a UITabBarController
as my rootController with 8 UITabBarItems
. and I want to show just 4 UITabBarItems
in my screen. By defaul
This is not currently a built-in option for UITabBarContoller
.
One way to approach the problem is to add a UIGestureRecognizer
to the tabBar.view
, and programmatically adjust which 4 options are available on the screen. You can add an animation to make it smooth or have a little bounce as it slides.
iPhone users are usually very picky and attached to Apple's UI Guidelines. Although you can pass the Apple verification, you probably wont be able to pass users' (meaning bad reviews and ratings). So I recommend you to re-consider your tabbar structure and use "..." More instead of sliding it... You can always override stuff in code, but then they wont work smooth with InterfaceBuilder and in the end you will have more trouble than you'd expect.
If you have similar tab items merge them and use maybe a segmented control or something to visually distinguish them. Or use a central navigation screen in which you can put 9 maybe more icons in a grid...
The first solution to your problem may not always be the best way. Well, it is very rare actually...
There is a nifty little github project that could help you... check it out: https://github.com/iosdeveloper/InfiniTabBar
You have to write a custom control for this. I wrote one for showing a horizontal menu. You can probably modify that to fit your needs. http://blog.mugunthkumar.com/coding/ios-control-mkhorizmenu/