转发:http://www.cnblogs.com/qianLL/p/5521228.html
 
方式一 
代码实现 这种要写很多代码 ,每个控制器都要写 
 UIImage *image=[UIImage imageNamed:@"tabBar_friendTrends_click_icon"];
//    不让tabbar底部有渲染的关键代码
     image=[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    vc01.tabBarItem.selectedImage=image;
 
更改tabbar下方的文字样式,大小, 颜色
  NSMutableDictionary *atts=[NSMutableDictionary dictionary];
// 更改文字大小
    atts[NSFontAttributeName]=[UIFont systemFontOfSize:12];
// 更改文字颜色
    atts[NSForegroundColorAttributeName]=[UIColor darkGrayColor];
 
    NSMutableDictionary *selectedAtts=[NSMutableDictionary dictionary];
    selectedAtts[NSFontAttributeName]=[UIFont systemFontOfSize:12];
    selectedAtts[NSForegroundColorAttributeName]=[UIColor greenColor];
    [vc01.tabBarItem setTitleTextAttributes:selectedAtts forState:UIControlStateSelected];
 
 
方式二  
 
在 Assets.xcassets文件夹中更改 改变之后不用代码  并且在所有的控制器里面都会被作用到
具体操作
 
appearance属性
//    通过appearance统一设置所有的UITabBarItem的文字属性
//    后面带有UI_APPEARANCE_SELECTOR的方法,都可以通过appearance同意设置
例如UITabBarItem的文字属性
案例; 
    NSMutableDictionary *atts=[NSMutableDictionary dictionary];
    atts[NSFontAttributeName]=[UIFont systemFontOfSize:12];
    atts[NSForegroundColorAttributeName]=[UIColor grayColor];
   
    NSMutableDictionary *selectedAtts=[NSMutableDictionary dictionary];
    selectedAtts[NSFontAttributeName]=atts[NSFontAttributeName];
    selectedAtts[NSForegroundColorAttributeName]=[UIColor darkGrayColor];
// 在这里 只要更改,所有的文字都改
 
    UITabBarItem *item=[UITabBarItem appearance];
    [item setTitleTextAttributes:atts forState:UIControlStateNormal];
    [item setTitleTextAttributes:selectedAtts forState:UIControlStateSelected];
   
    //    添加子控制器
    UIViewController *vc01=[[UIViewController alloc]init];
    vc01.view.backgroundColor=[UIColor redColor];
    vc01.tabBarItem.title=@"精华";
    vc01.tabBarItem.image=[UIImage imageNamed:@"tabBar_essence_icon"];
    UIImage *image=[UIImage imageNamed:@"tabBar_friendTrends_click_icon"];
//    不让tabbar底部有渲染的关键代码
     image=[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    vc01.tabBarItem.selectedImage=image;
// 把控制器 添加到 UITabBarController里面去
    [self addChildViewController:vc01];
   
    UIViewController *vc02=[[UIViewController alloc]init];
    vc02.tabBarItem.title=@"新帖";
    vc02.tabBarItem.image=[UIImage imageNamed:@"tabBar_new_click_icon"];
    vc02.tabBarItem.selectedImage=[UIImage imageNamed:@"tabBar_new_click_icon"];
    vc02.view.backgroundColor=[UIColor cyanColor];
    [self addChildViewController:vc02];
   
    UIViewController *vc03=[[UIViewController alloc]init];
    vc03.view.backgroundColor=[UIColor blueColor];
    vc03.tabBarItem.title=@"关注";
    vc03.tabBarItem.image=[UIImage imageNamed:@"tabBar_friendTrends_icon"];
    vc03.tabBarItem.selectedImage=[UIImage imageNamed:@"tabBar_friendTrends_click_icon"];
    [self addChildViewController:vc03];
   
    UIViewController *vc04=[[UIViewController alloc]init];
    vc04.tabBarItem.title=@"我";
    vc04.tabBarItem.image=[UIImage imageNamed:@"tabBar_me_icon"];
    vc04.tabBarItem.selectedImage=[UIImage imageNamed:@"tabBar_me_click_icon"];
    vc04.view.backgroundColor=[UIColor yellowColor];
    [self addChildViewController:vc04];

iOS之tabbar图片去除渲染以及字体颜色统一配置的更多相关文章

  1. IOS 修改UIAlertController的按钮标题的字体颜色,字号,内容

    IOS 修改UIAlertController的按钮标题的字体颜色,字号,内容 UIAlertController *alertVC = [UIAlertController alertControl ...

  2. 【转】iOS中设置导航栏标题的字体颜色和大小

    原文网址:http://www.360doc.com/content/15/0417/11/20919452_463847404.shtml iOS中设置导航栏标题的字体颜色和大小,有需要的朋友可以参 ...

  3. iOS中设置导航栏标题的字体颜色和大小

    iOS中设置导航栏标题的字体颜色和大小,有需要的朋友可以参考下. 在平时开发项目的时候,难免会遇到修改导航栏字体大小和颜色的需求,一般使用自定义视图的方法,其实还存在一种方法. 方法一:(自定义视图的 ...

  4. iOS更改tabbar图片渲染 —不让tabbat有蓝色的渲染 并修改文字

    方式一  代码实现 这种要写很多代码 ,每个控制器都要写   UIImage *image=[UIImage imageNamed:@"tabBar_friendTrends_click_i ...

  5. python设置图片背景和设置字体颜色大小

    # -*- coding: utf-8 -*- """ Created on Wed Dec 11 22:37:30 2019 @author: Dell "& ...

  6. iOS 8 TabBar 图片显示真实颜色

    “展信颜开” 我怎么想到这个词了呢……因为这个足以表达我现在的心情,有解决了一个问题,有了一个收获. 早上小伙伴问我“用自带的tab改图的颜色他会不显示?改tabitem.”我记得是可以显示的,但是他 ...

  7. iOS 修改UITextField的placeholder属性的字体颜色(修改UITextField占位符字体的颜色)

    只要把原来的placeholder属性改为attributedPlaceholder属性即可 具体代码如下图:

  8. iOS如何把所有页面状态栏的字体颜色都设置为白色

    第一步:在info.plist中添加一个字段:view controller -base status bar 设置为NO 第二步:在一个所有界面都继承的父类里添加: if (IOS7_OR_LATE ...

  9. iOS设置图片名称、启动图片、防止TabBar图片和文字渲染

    设置App的名称 设置App的启动图片 需要注意点是,App要杀掉重启才能显示出启动图片 2种方法防止图片被渲染 1. vc02.tabBarItem.image = [UIImage imageNa ...

随机推荐

  1. JDK和JRE的区别

    JDK(Java Development Kit)是针对Java开发员的产品,是整个Java的核心,包括了Java运行环境JRE.Java工具和Java基础类库.Java Runtime Enviro ...

  2. 通过C++修改系统时间代码

    #include <windows.h>#include <stdio.h>#include <iostream>using namespace std;int m ...

  3. vb脚本自动更新版本信息

    使用的串口显示软件为secureCrt,支持脚本功能,今天写了一个简单的软件升级脚本(VB脚本). 如下: # $language = "VBScript" # $interfac ...

  4. updating the chroot

    Ubuntu may stop working after a Chrome OS update. If that's the case, update all the installed targe ...

  5. 第一天学习oc用xcode做的一个加减乘除 圆的面积计算

    #import <Foundation/Foundation.h>  //这是oc的框架 @interface jisuan : NSObject  //申明一个jisuan这样的类 并继 ...

  6. .Cannot create an NSPersistentStoreCoordinator with a nil model

    今天用coredata事,忽然遇到这个问题:找了一会终于发现问题所在,与大家分享一下 导致这个问题的原因是因为找不到.xcdatamodeld所致,不同的人可能遇到的问题不同 可能原因1: NSURL ...

  7. 学习最短路建图 HUD 5521

    http://acm.hdu.edu.cn/showproblem.php?pid=5521 题目大意:有n个点,m个集合,每个集合里面的点都两两可达且每条边权值都是val,有两个人A, B,A在po ...

  8. hibernate ——联合主键

    接上一篇博客:http://www.cnblogs.com/tengpan-cn/p/5551323.html 主键类不需要写任何注解,表对象类使用@IdClass注解 在表对象类前面加@IdClas ...

  9. Response.Flush()

    Response.Buffer=True就是在缓存网页 访问网站一般是程序直接输出网页结果,或从缓存中读取网页结果2种方式.两种方式在速度上是有差异的 设置 Response.Buffer = Tru ...

  10. git push origin master 报错 remote rejected] master -> master (branch is currently checked out)

    解决办法: 977down vote You can simply convert your remote repository to bare repository (there is no wor ...