标签导航,既底部为标签,几个标签内容组成:
标签内容需要
第一步,模块继承UINavigationController作为标签内容,绑定vc:
MainMineViewController * _mineVc = [[MainMineViewController alloc]init];
_mineVc.hidesBottomBarWhenPushed = NO;
UINavigationController *mineNav = [[UINavigationController alloc] initWithRootViewController:_mineVc];
第二步,创建标签项目:tabBarItem
mineNav.tabBarItem = [self createTabBarItemWithTitle:@"我的" normalImageName:@"tab_main_mine_normal" selectedImageName:@"tab_main_mine_selected"];
方法
- (UITabBarItem *)createTabBarItemWithTitle:(NSString *)title
normalImageName:(NSString *)normalName
selectedImageName:(NSString *)selectedName {
UIImage *image = [[self scaledImageFromImage:[UIImage imageNamed:normalName]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIImage *selectedImage = [[self scaledImageFromImage:[UIImage imageNamed:selectedName]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:title image:image selectedImage:selectedImage];
[item setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:12], NSFontAttributeName, MAIN_THEME_COLOR, NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];
[item setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:12], NSFontAttributeName,[UIColor grayColor] , NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
return item;
}
第三步,标签内容项,添加到viewControllers属性中
self.viewControllers=@[UINavigationController子项...];