//视图
RSHomeViewController * homeViewCtrl = [[RSHomeViewController alloc]init];
//加导航
RSBaseNavigationController * homeNavigationCtrl = [[RSBaseNavigationController alloc]initWithRootViewController:homeViewCtrl];
设置图片 (用原图!)
homeViewCtrl.tabBarItem.image = [[UIImage imageNamed:_defaultImage[0]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
// 选中图片
homeViewCtrl.tabBarItem.selectedImage = [[UIImage imageNamed:_selectedImage[0]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];;
//标题
homeViewCtrl.tabBarItem.title = @"首页";
// 设置字体颜色
[homeViewCtrl.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor yellowColor]} forState:UIControlStateSelected];
ps : title 设置注意
childViewController.title = title
childViewController.navigationItem.title = title
childViewController.tabBarItem.title = title
如果用上面一句就会设置成统一的文字
如果用下面两句,则可以实现 tabBar 文字与导航栏 title 不同
ps: 字体颜色设置 两种方法
[UITabBar appearance].tintColor = [UIColor colorWithRed:254.0/225 green:159.0/225 blue:10.0/225 alpha:1];
[homeViewCtrl.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor yellowColor]} forState:UIControlStateSelected];
ps: 字体 和 颜色
[viewController.tabBarItem setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor colorWithHexString:@"#584E60"],NSFontAttributeName:[UIFont fontWithName:@"Helvetica" size:9.0]} forState:UIControlStateNormal];