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. Linux上程序执行的入口--Main

    main()函数,想必大家都不陌生了,从刚开始写程序的时候,大家便开始写main(),我们都知道main是程序的入口.那main作为一个函数,又是谁调用的它,它是怎么被调用的,返回给谁,返回的又是什么 ...

  2. 摄像头(4)用Camera和SurfaceView自定义拍照程序

    定制拍照程序的基本步骤 1,打开照相机:Camera.open 这是独占方式打开的 2,创建SurfaceView对象 多缓冲,多线程view 3,添加回调事件监听器(SurfaceHolder.ad ...

  3. Number of Rectangles in a Grid

    Project Euler 85: Investigating the number of rectangles in a rectangular grid Number of Rectangles ...

  4. oracle必须启动的服务

    按照windows 7 64位 安装oracle 11g R2中的方法成功安装Oracle 11g后,共有7个服务,这七个服务的含义分别为: 1. Oracle ORCL VSS Writer Ser ...

  5. 【 D3.js 高级系列 — 1.0 】 文本的换行

    在 SVG 中添加文本是使用 text 元素.但是,这个元素不能够自动换行,超出的部分就显示不出来了,怎么办呢? 高级系列开篇前言 从今天开始写高级系列教程.还是那句话,由于本人实力有限,不一定保证入 ...

  6. MenuInflater用法

    MenuInflater是用来加载menu布局文件的. 与LayoutInflater类似,应用程序运行时会预先加载资源中的布局文件,如果Menu布局中的资源比较多,会影响性能,所以可以选择MenuI ...

  7. insert /*+APPEND*/ 各种insert 插入速度比较

    SQL> select count(*) from t;COUNT(*)----------5442048****************************SQL> alter ta ...

  8. 单点登录技术:微软Passport单点登录协议和自由联盟规范

    随着互联网络应用的普及,越来越多的人开始使用互联网上提供的服务.然而目前提供服务的网站大多采用用户名.口令的方式来识别用户身份,这使得用户需要经常性的输入自己的用户名.口令.显然这种认证方式存在着弊端 ...

  9. Datatable转成Json方式两则

    1, Asp.net C# 使用Newtonsoft.Json 实现DataTable转Json格式数据 1.这里下载:http://www.newtonsoft.com/products/json/ ...

  10. GTK+布局管理

    GTK+布局管理 GTK+ 布局管理 在本章中,我们将讲述如何将构件布置在窗口与对话框中. 当我们在设计应用程序的图形界面时,我们首先要决定的是在程序中用到哪种构件和管理应用程序中的这些构件.为了方便 ...