系统自动默认渲染
本来的tabBarItem.image的是黑色的

然而运行时的颜色就变成系统默认的蓝色

下面就是取消渲染的方法
tabBarItem.image取消渲染
把要取消默认渲染的标签image进行以下操作

tabBarItem.title取消渲染
在_TabBarController.m文件中写下以下代码
NSMutableDictionary * attrs = [NSMutableDictionary dictionary];
attrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
attrs[NSForegroundColorAttributeName] = [UIColor grayColor];
NSMutableDictionary * dataAttrs = [NSMutableDictionary dictionary];
dataAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
dataAttrs[NSForegroundColorAttributeName] = [UIColor grayColor];
UITabBarItem * item = [UITabBarItem appearance];
[item setTitleTextAttributes:attrs forState:UIControlStateNormal];
[item setTitleTextAttributes:dataAttrs forState:UIControlStateSelected];
因为只要有UI_APPEARANCE_SELECTOR就可以进行统一设置所以上面代码只要设置一次,不需要在标签控制器的每个子视图都去设置一次了。

网友评论