A customisable tab bar controller for iOS written in Objective C. It uses auto layout.
- iOS 7.1 +
- ARC
- Icon image
- Selected and unselected background image
- Uses autolayout
- You can set custom background images, icons and text( custom font and colour) for selected, unselected states of the tabs.
- There are two configurations for the arrangement of text and icon image (Text to the right of icon image and text to the bottom of icon image)
- You can assign controllers for each of the tabs.
- NMBottomTabBarController will take care of the switching and displaying of the controller views when user switches the tabs.
- In addition the tabs can be switched programatically as required.
- Please Download the source files
- Drag and drop the NMBottomTabBarController folder into your project
- Include
objective-c #import "NMBottomTabBarController.h"wherever necessary
Add a controller and change its custom class to NMBottomTabBarController.
From the controller where you want to display the tab bar controller you can do the initial set up.
UIViewController *oneController = [UIViewController new];
oneController.view.backgroundColor = [UIColor greenColor];
UIViewController *twoController = [UIViewController new];
twoController.view.backgroundColor = [UIColor blueColor];
UIViewController *threeController = [UIViewController new];
threeController.view.backgroundColor = [UIColor purpleColor];
UIViewController *fourController = [UIViewController new];
fourController.view.backgroundColor = [UIColor orangeColor];
NMBottomTabBarController *tabBarController = (NMBottomTabBarController *)self.window.rootViewController;
tabBarController.controllers = [NSArray arrayWithObjects:oneController,twoController,threeController,fourController, nil]; tabBarController.tabBar.separatorImage = [UIImage imageNamed:@"separator.jpg"];There are two title and text orientations
- kTitleToRightOfIcon - Places title to the right of the icon image
- kTItleToBottomOfIcon - Places title to the nottom of the icon image You can learn how to set these in the next step
[tabBarController.tabBar configureTabAtIndex:0 andTitleOrientation :kTitleToRightOfIcon withUnselectedBackgroundImage:[UIImage imageNamed:@"unselected.jpeg"] selectedBackgroundImage:[UIImage imageNamed:@"selected.jpeg"] iconImage:[UIImage imageNamed:@"home"] andText:@"Home"andTextFont:[UIFont systemFontOfSize:12.0] andFontColour:[UIColor whiteColor]]; [tabBarController selectTabAtIndex:0];There are two delegates available for NMBottomTabBarController
-(BOOL)shouldSelectTabAtIndex : (NSInteger)index;It can be used to determine whether to allow the selection of a particular tab
-(void)didSelectTabAtIndex : (NSInteger)index;It can be used to perform any action once a tab is selected
- Set selected and unselected attributed text, icon images
- Add a more button and display the controllers on next page when the tabs exceed a certain limit.
The project is licensed under the MIT license. For more information please see the [LICENSE][https://github.com/priankaliz/NMBottomTabBarController/blob/master/LICENSE] file
NMBottomTabBarController was developed for a project I work on. Please feel free to reach me at priankaliz@gmail.com