美文网首页
标签栏tabBarItem.image和tabBarItem.t

标签栏tabBarItem.image和tabBarItem.t

作者: 梦醒繁华 | 来源:发表于2016-07-16 19:26 被阅读192次

系统自动默认渲染

本来的tabBarItem.image的是黑色的


本来图片颜色.png

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


系统默认的渲染颜色.png

下面就是取消渲染的方法

tabBarItem.image取消渲染

把要取消默认渲染的标签image进行以下操作

步骤.png

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就可以进行统一设置所以上面代码只要设置一次,不需要在标签控制器的每个子视图都去设置一次了。

123.png

相关文章

网友评论

      本文标题:标签栏tabBarItem.image和tabBarItem.t

      本文链接:https://www.haomeiwen.com/subject/aqeujttx.html