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
UITabBarController
as your root view and connect all your child view controllers to it as you normally would - Change the class of that
UITabBarController
toCJMSimpleScrollingTabBar
- 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;
-
kCJMTabBarMaxButtonsOnScreen
is the number of buttons that will be display on the screen before the user needs to scroll -
kCJMTabBarInitialButtonIndex
is 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];
....
}
barTintColor
controls the background color of your tab bartintColor
controls 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 :)