How to make horizontal scrollable UITabBar in iOS?

The UITabBar in my application consists of 10 elements, but the width is enough to fit all 10 objects.

How to make horizontal scrollable UITabBar in iOS?

Thanks.

+5
source share
3 answers

You will have to roll on your own, at least to some extent.

What could possibly work would be to create a UITabBar view (not a controller) and embed it in a UIScrollView. You can then use this instead of your regular Tab Bar control by adding it to your TabBarController.view / tabBarView or something like that. Of course, you will have to play to make it look right, and I'm not sure if just adjusting the view to something wider will make it display more objects or not.

Of course, for best results, you probably want to do something completely ordinary.

+4
source

From the Apple Developer Portal:

If you add more than five elements to the viewControllers property, the tab bar controller automatically inserts a special view controller (called a larger controller) to handle the display of additional elements. A source

It looks like you need to create your own tab bar.

They also said this in the following paragraph:

Although the tab bar view is a key part of the tab bar interface, you do not change this view directly. You may violate Apple's design principles by doing so.

+2
source

You can go and create a custom UITabBar class (by embedding it in scrollview, etc.) .. but why reinvent the wheel? After searching, I found that several third-party classes have already been created that work well and are easy to use and customizable. In order of personal preference:

M13InfiniteTabBar - https://github.com/Marxon13/M13InfiniteTabBar

JSScrollableTabBar - https://github.com/jasarien/JSScrollableTabBar

InfiniTabBar - https://github.com/iosdeveloper/InfiniTabBar

+2
source

Source: https://habr.com/ru/post/946082/


All Articles