解决iOS中tabBarItem图片默认颜色的问题(指定代码渲染模式为以原样模式的方式显示出来)

解决iOS中tabBarItem图片默认颜色的问题(指定代码渲染模式为以原样模式的方式显示出来)

解决办法:指定图片的渲染模式(imageWithRenderingMode为:UIImageRenderingModeAlwaysOriginal模式)

代码示例:

//image
 childController.tabBarItem.image = [[UIImage imageNamed:imageName]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//title
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
dict[NSForegroundColorAttributeName] = [UIColor orangeColor];
//指定选中下的titile的颜色
[childController.tabBarItem setTitleTextAttributes:dict forState:UIControlStateSelected];

posted @ 2015-12-21 15:02  J_mailbox  阅读(1090)  评论(0编辑  收藏  举报