custom scrollable tab bar on top iOS

前端 未结 4 1030
灰色年华
灰色年华 2021-01-03 01:04

I have a question about implementing a custom scrollable tab bar at the top of the screen in an iOS app. I am looking for a a tab bar very similar to the vevo app (pictured

相关标签:
4条回答
  • 2021-01-03 01:28

    You can have a look at this library: https://github.com/raihan/ZRScrollableTabBar. Which is simple and lightweight and may help you.

    0 讨论(0)
  • 2021-01-03 01:38

    this project may help you: https://github.com/Marxon13/M13InfiniteTabBar but you need

    Consist in a infinite UITabBar with a UIScrollView embedded in it ;) and it can be configure to put the tabbar in top of screen.

    enter image description here

    Hope it helps!

    0 讨论(0)
  • 2021-01-03 01:38

    I was looking for a similar solution, but ended up coming up with my own and wanted to share for anyone that might be looking at this later.

    https://github.com/chrismanahan/Simple-Scrolling-Tab-Bar

    It's a super simple way to create a sliding tab bar with the standard UITabBarController in your storyboard.

    0 讨论(0)
  • 2021-01-03 01:41

    Basically, you'd do something like the following:

    @class CustomTabBar;
    
    @protocol CustomTabBarDatasource <NSObject>
    - (int)numberOfElementsInCustomTabBar:(CustomTabBar *)bar;
    - (NSString *)titleForTabAtIndex:(int)index inCustomTabBar:(CustomTabBar *)bar;
    @end
    
    @protocol CustomTabBarDelegate <NSObject>
    - (void)customTabBar:(CustomTabBar *)bar activatedTabAtIndex:(int)index;
    @end
    
    @interface CustomTabBar : UIView
    @property (weak) id<CustomTabBarDataSource> dataSource;
    @property (weak) id<CustomTabBarDelegate> delegate;
    @end
    
    @interface YourViewController : UIViewController {
      CustomTabBar *myTabBar;
    }
    @end
    
    @interface YourViewController (TabBarDataSource) <CustomTabBarDataSource>
    @end
    
    @interface YourViewController (TabBarDelegate) <CustomTabBarDelegate>
    @end
    

    The implementation for your CustomTabBar would include a UIScrollView and a set of UIButtons, whose title you would retrieve from the dataSource. When a button is fired, you'd call the delegate's customTabBar:activatedTabAtIndex: method. Your YourViewController would change its content when the delegate method fires.

    0 讨论(0)
提交回复
热议问题