//设置tabbar的图片和文字(但是图片显示为系统默认颜色,不会渲染为图片本身颜色)
vc.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"title" image:[UIImage imageNamed:icon] selectedImage:[UIImage imageNamed:sIcon]];
//设置选中状态图片和文字颜色
[[UITabBar appearance] setTintColor:self.baseColor];
下面这个方法是渲染图片本身颜色,且改变文字的size和font(选中和非选中状态都是可以设置的)
vc.navigationItem.title = title;
//特别注意这个title,有一次没有赋值文字一直不出来。
vc.title = title;
vc.tabBarItem.image = [[UIImage imageNamed:icon]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];;
vc.tabBarItem.selectedImage = [[UIImage imageNamed:sIcon]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
// 设置文字的样式
NSMutableDictionary *selectTextAttrs = [NSMutableDictionary dictionary];
selectTextAttrs[NSForegroundColorAttributeName] = [AppContext sharedAppContext].baseColor;
[vc.tabBarItem setTitleTextAttributes:selectTextAttrs forState:UIControlStateSelected];