UITabBarItem的selectedImage
2015-10-11 14:04
357 查看
TabBar使用频率很高的一个组件,TabBar的TabBarItem有两个属性一个是image(未选中图片),另一个是selectedImage(选中时图片)
![](http://images2015.cnblogs.com/blog/799670/201510/799670-20151011135622503-1483114614.png)
但是运行时发现,选中时的图片变成了蓝色的,但是实际上图片是红色的,看来系统的TabBar会对图片默认使用TintColor再进行渲染。
解决方法:
1.设置渲染色
self.tabBarController.tabBar.tintColor = [UIColor blackColor];
2.设置图片不进行渲染
self.tabBarItem.selectedImage = [[UIImage imageNamed:@"XX"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
TabBarItem上标题颜色也可以修改
[self.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor],NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];
![](http://images2015.cnblogs.com/blog/799670/201510/799670-20151011135622503-1483114614.png)
但是运行时发现,选中时的图片变成了蓝色的,但是实际上图片是红色的,看来系统的TabBar会对图片默认使用TintColor再进行渲染。
解决方法:
1.设置渲染色
self.tabBarController.tabBar.tintColor = [UIColor blackColor];
2.设置图片不进行渲染
self.tabBarItem.selectedImage = [[UIImage imageNamed:@"XX"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
TabBarItem上标题颜色也可以修改
[self.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor],NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];
相关文章推荐
- 关于UITextView的几种回收键盘的方法
- POJ1141 Brackets Sequence (最小括号匹配升级版:区间DP+打印路径)
- android requestDisallowInterceptTouchEvent用途
- Unique Paths II
- 黑马程序员--NSValue的使用
- [BZOJ1626] [Usaco2007 Dec]Building Roads 修建道路
- Leetcode Unique Word Abbreviation
- 快速排序quicksort
- 创建自己的循环Queue底层使用数组java版
- IOS UIBarButtonItem 位置偏移的问题
- 给iOS工程增加Daily Build
- 创建自己的Queue底层实现是链表
- 创建自己的队列Queue底层实现利用数组
- win10 Build 10558预览版《微软电话》应用曝光 内附下载
- 在storyBoard中添加UIScrollView并添加相应的约束
- UE4蓝图案例:制作实时反射镜面材质
- android 5.0UI特效
- poj 2778 DNA Sequence 【AC自动机 + 矩阵加速】
- 《腾讯网UED体验设计之旅》
- easyui-datagrid行数据field原样输出html标签