UITbarController之前有在这篇文章讲解:http://www.cnblogs.com/niit-soft-518/p/4447940.html

如果自定义了UITabBarItem的图片,用上述文章创建的时候,发现选中的图的边框颜色默认是蓝色的,

解决这个问题就需要设置 UIImage的渲染模式

imageWithRenderingMode
设置UIImage的渲染模式:UIImage.renderingMode

着色(Tint Color)是iOS7界面中的一个.设置UIImage的渲染模式:UIImage.renderingMode重大改变,你可以设置一个UIImage在渲染时是否使用当前视图的Tint Color。UIImage新增了一个只读属性:renderingMode,对应的还有一个新增方法:imageWithRenderingMode:,它使用UIImageRenderingMode枚举值来设置图片的renderingMode属性。该枚举中包含下列值:

UIImageRenderingModeAutomatic  // 根据图片的使用环境和所处的绘图上下文自动调整渲染模式。
UIImageRenderingModeAlwaysOriginal // 始终绘制图片原始状态,不使用Tint Color。
UIImageRenderingModeAlwaysTemplate // 始终根据Tint Color绘制图片,忽略图片的颜色信息。

 
如需使用自定义颜色的选中图时,需设置UIImageRenderingModeAlwaysOriginal。
示例: UITabBarItem *tabBar ;
tabBar. selectedImage =[[UIImage imageNamed:@"bar_icon.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  //初始化controllers
{
FourViewController *one=[[FourViewController alloc]init]; UITabBarItem *itemOne=[[UITabBarItem alloc]initWithTitle:@"消息" image:[UIImage imageNamed:@"btn_message_nor"] selectedImage:[[UIImage imageNamed:@"btn_message_sel"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
one.tabBarItem=itemOne;
[itemOne setTitleTextAttributes:[NSDictionary dictionaryWithObject:KDEFAULT_COLOE forKey:NSForegroundColorAttributeName] forState:UIControlStateHighlighted];
[controllers addObject:one];
}
{
FiveViewController *five=[[FiveViewController alloc]init]; UITabBarItem *itemFive=[[UITabBarItem alloc]initWithTitle:@"我的" image:[UIImage imageNamed:@"btn_me_nor"] selectedImage:[[UIImage imageNamed:@"btn_me_sel"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
five.tabBarItem=itemFive;
[itemFive setTitleTextAttributes:[NSDictionary dictionaryWithObject:KDEFAULT_COLOE forKey:NSForegroundColorAttributeName] forState:UIControlStateHighlighted];
[controllers addObject:five];
}

iOS UITabBarItem 选中图的颜色,设置UIimage的渲染模式的更多相关文章

  1. 设置UIImage的渲染模式:UIImage.renderingMode

    设置UIImage的渲染模式:UIImage.renderingMode 着色(Tint Color)是iOS7界面中的一个.设置UIImage的渲染模式:UIImage.renderingMode重 ...

  2. iOS开发UITableViewCell的选中时的颜色设置(转)

    iOS开发UITableViewCell的选中时的颜色设置   1.系统默认的颜色设置 //无色 cell.selectionStyle = UITableViewCellSelectionStyle ...

  3. 【转】iOS开发UITableViewCell的选中时的颜色设置

    原文网址:http://mobile.51cto.com/hot-404900.htm 1.系统默认的颜色设置 //无色 cell.selectionStyle = UITableViewCellSe ...

  4. iOS开发UITableViewCell的选中时的颜色设置

    1.系统默认的颜色设置 //无色 cell.selectionStyle = UITableViewCellSelectionStyleNone; //蓝色 cell.selectionStyle = ...

  5. UITableViewCell的选中时的颜色设置

    转自:http://hi.baidu.com/zhu410289616/item/0de0262910886011097508c2 1.系统默认的颜色设置 //无色 cell.selectionSty ...

  6. 设置WebBrowser内核渲染模式

    前不久开发一个项目,是采用WebBrowser作为外壳,加载网页,由于网页是采用html5来进行开发的,当通过WebBrowser加载网页后,html5中的特性 都无法正常显示,而通过ie浏览器打开时 ...

  7. notepad++中双击选中字符串高亮颜色设置

    notepad++ 中最好用的功能就是双击选中,本文档中所有相同的内容高亮 不过有个问题就是当文档特别大,而且注释比较多的时候,我选中的内容高亮为绿色不太好找,那怎么设置呢? 设置--语言格式设置-- ...

  8. IOS 创建一张有颜色的UIImage

    #import <UIKit/UIKit.h> @interface UIImage (ImageWithColor) + (UIImage *)imageWithColor:(UICol ...

  9. iOS导航栏的背景颜色设置

    方法一: (1) self.navigationController.navigationBar.barStyle = UIBarStyleDefault; self.navigationContro ...

随机推荐

  1. 【HDOJ】3686 Traffic Real Time Query System

    这题做了几个小时,基本思路肯定是求两点路径中的割点数目,思路是tarjan缩点,然后以割点和连通块作为新节点见图.转化为lca求解.结合点——双连通分量与LCA. /* 3686 */ #includ ...

  2. myhuiban会议,期刊,科研人员,计算机类会议大全

    http://www.myhuiban.com/ List of computer science conferences From Wikipedia, the free encyclopedia ...

  3. poj 3321 Apple Tree(一维树状数组)

    题目:http://poj.org/problem?id=3321 题意: 苹果树上n个分叉,Q是询问,C是改变状态.... 开始的处理比较难,参考了一下大神的思路,构图成邻接表 并 用DFS编号 白 ...

  4. 4月数据库流行度排行榜 MySQL能否追上Oracle

    4月的数据库流行度排行榜可谓看点十足.闲言少叙,先上图: 前十名中,名次上升的都是NoSQL数据库,NoSQL凭借其对大数据处理的优势,发展越来越快.NoSQL是对众多非传统关系型数据库的总称,按存储 ...

  5. CDN-内容推送网络

    前段时间介绍了浏览器缓存机制,通过浏览器缓存一方面可以改善用户的体验,而不用漫长地等待从服务器下载资源:另一方面减轻服务器压力.节省流量.CDN是另一种可以大幅度优化用户体验,且减轻服务器压力的技术. ...

  6. Java [leetcode 15] 3Sum

    问题描述: Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find ...

  7. HDU 1075-What Are You Talking About(Trie)

    题意: 给你一个字典 一个英文单词对应一个火星单词 给你一段火星文翻译成英文 字典上的没有的不翻译 分析: 没有给数据规模 字典树用链表 #include <map> #include & ...

  8. Serv-U搭建FTP服务器

    1.打开软件,勾选start automatically 2.点击domain,新建domain 3.依次输入IP.端口号.域名.域名类型 完成后的样子 4.右键单击Users,新建用户.依次输入用户 ...

  9. 5个最优秀的Java和C#代码转换工具

    http://www.codeceo.com/article/5-java-csharp-convert-tools.html 毋庸置疑,Java是一门最受欢迎而且使用最广泛的编程语言,目前有超过9百 ...

  10. POJ3264 Balanced Lineup 线段树区间最大值 最小值

    Q个数 问区间最大值-区间最小值 // #pragma comment(linker, "/STACK:1024000000,1024000000") #include <i ...