NMBottomTabBarController
A customisable tab bar controller for iOS written in Objective C. It uses auto layout.
一个自定义的Tabbar控制器,使用了自动布局。
objective-c #import "NMBottomTabBarController.h"
wherever necessary 在需要的地方引入头文件NMBottomTabBarController.h
Add a controller and change its custom class to NMBottomTabBarController.
添加一个控制器,然后让他继承自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
有两种文本显示方式:
[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
NMBottomTabBarController提供两个代理方法:
-(BOOL)shouldSelectTabAtIndex : (NSInteger)index;
It can be used to determine whether to allow the selection of a particular tab
这个可以用来决定是否允许某个tab被选中:
-(void)didSelectTabAtIndex : (NSInteger)index;
It can be used to perform any action once a tab is selected
这个可以用来执行任何的操作,当某个tab被选中的时候
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[email protected]