框架定义了UITabBarController的子类JMTabBarController
所有关于UITabBarController的设置都是在JMTabBarController中完成
设置属性
//未选中的字体颜色
UIColor *colorUnselect = [UIColor blackColor];
[[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:colorUnselect} forState:UIControlStateNormal];
//选中的字体颜色
UIColor *colorSelect = [UIColor redColor];
[[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:colorSelect} forState:UIControlStateSelected];
//设置不透明
self.tabBar.translucent = NO;
//设置背景颜色
self.tabBar.barTintColor = [UIColor whiteColor];
//设置背景图片
[self.tabBar setBackgroundImage:nil];
//设置阴影图
[self.tabBar setShadowImage:nil];
一些常用属性设置已经给出,只要做一些修改即可。如果没有,可以在此处自行增加。
设置item
NSMutableArray *viewControllers = [[NSMutableArray alloc] init];
HomeViewController *vc1 = [[HomeViewController alloc] initWithStoryboardName:@"Home"];
JMNavigationController *nav1 = [[JMNavigationController alloc] initWithRootViewController:vc1];
[self setupBarItem:nav1.tabBarItem normalImageName:@"Tab1" selectImageName:@"Tab1_Select"];
[nav1.tabBarItem setTitle:@"主页"];
[viewControllers addObject:nav1];
在setupViewControllers方法中已经给出例子,在此处更改相应的item,并且在图片资源Assets.xcassets中设置tab文件夹下对应的图片
image.png