在iOS8系统下,UITabbar上的item自定义背景色和图片问题
2016-04-17 21:14
337 查看
在iOS8系统下,UITabbar上的item自定义背景色和图片,初始设置了红色没效果系统默认颜色-蓝色
解决方法:
//选择的图片
UITabBar *tabBar = self.tabBar;
UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0];
UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:1];
UITabBarItem *tabBarItem3 = [tabBar.items objectAtIndex:2];
tabBarItem1.title =@"title1";
tabBarItem2.title = @"title2";
UIImage* selectedImage = [UIImage imageNamed:@"xxxx.png"];
//声明这张图片用原图(别渲染)
selectedImage = [selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[tabBarItem1setFinishedSelectedImage:selectedImagewithFinishedUnselectedImage:[UIImage imageNamed:@"xxx.png"]];
[tabBarItem2setFinishedSelectedImage:[UIImage imageNamed:@"xxxx.png"]withFinishedUnselectedImage:[UIImage imageNamed:@"xxxx.png"]];
解决方法:
//选择的图片
UITabBar *tabBar = self.tabBar;
UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0];
UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:1];
UITabBarItem *tabBarItem3 = [tabBar.items objectAtIndex:2];
tabBarItem1.title =@"title1";
tabBarItem2.title = @"title2";
UIImage* selectedImage = [UIImage imageNamed:@"xxxx.png"];
//声明这张图片用原图(别渲染)
selectedImage = [selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[tabBarItem1setFinishedSelectedImage:selectedImagewithFinishedUnselectedImage:[UIImage imageNamed:@"xxx.png"]];
[tabBarItem2setFinishedSelectedImage:[UIImage imageNamed:@"xxxx.png"]withFinishedUnselectedImage:[UIImage imageNamed:@"xxxx.png"]];
相关文章推荐
- LeetCode *** 63. Unique Paths II
- HDUOJ 5667 Sequence
- php中require,include,use区分
- POJ 1458 Common Subsequence(最长公共子序列LCS)
- HDU1503:Advanced Fruits(LCS)
- VMware共享文件夹编译出现“Value too large for defined data type”错误的解决办法
- build-essential: 依赖: g++ (>= 4:4.3.1) 但是它将不会被安装
- UIDynamic 基础
- leetcode——63—— Unique Paths II
- reason: 'UITableView failed to obtain a cell from its dataSource'
- njust sequence(二分查找)
- HDU5667 Sequence(矩阵快速幂)
- iOS开发——纯代码界面(UITabBarController,UINavigationController,UIImageView)
- LeetCode-51&52.N-Queens
- HDU 5667 Sequence【矩阵快速幂】【欧拉函数】
- HDU-5667 Sequence (矩阵快速幂)
- leetcode—— 62——Unique Paths
- SoapUI + Selenium Webdriver 自动化测试学习
- 从频率到意义:语义向量空间模型(2)(From Frequency to Meaning: Vector Space Models of Semantics)
- The server encountered an internal error that prevented it from fulfilling this request的一种解决办法