This is an implementation of UITabBarController that lets you easily add tabs using your storyboard and creates a scrolling tab bar with minimal configuration.
- In your storyboard, use a
UITabBarControlleras your root view and connect all your child view controllers to it as you normally would - Change the class of that
UITabBarControllertoCJMSimpleScrollingTabBar - Configure your new tab bar controller with a few changes in
CJMSimpleScrollingTabBar.m
- Constants you can leave or change, located at the top of
CJMSimpleScrollingTabBar.m
const CGFloat kCJMTabBarMaxButtonsOnScreen = 4;
const NSInteger kCJMTabBarInitialButtonIndex = 0;-
kCJMTabBarMaxButtonsOnScreenis the number of buttons that will be display on the screen before the user needs to scroll -
kCJMTabBarInitialButtonIndexis the first button that will be selected when the controller is loaded -
Things you should change
- (void)viewDidLoad {
[super viewDidLoad];
self.tabBar.barTintColor = [UIColor colorWithWhite:0.9 alpha:1.0];
self.tabBar.tintColor = [UIColor blueColor];
....
}barTintColorcontrols the background color of your tab bartintColorcontrols the color of the active button, just like the standard tab bar controller
That's it! Nothing else you need to do. Report issues if you run into any :)