Basically, you would 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 will include a UIScrollView and a set of UIButton s, the name of which you will get from the dataSource . When the button starts, you call the delegate method customTabBar:activatedTabAtIndex: Your YourViewController will change its contents when you run the delegate method.
source share