在iOS8系统下,UITabbar上的item自定义背景色和图片问题
2015-07-28 11:18
211 查看
在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];
[tabBarItem1 setFinishedSelectedImage:selectedImage withFinishedUnselectedImage:[UIImage
imageNamed:@"xxx.png"]];
[tabBarItem2 setFinishedSelectedImage:[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];
[tabBarItem1 setFinishedSelectedImage:selectedImage withFinishedUnselectedImage:[UIImage
imageNamed:@"xxx.png"]];
[tabBarItem2 setFinishedSelectedImage:[UIImage imageNamed:@"xxxx.png"]withFinishedUnselectedImage:[UIImage
imageNamed:@"xxxx.png"]];
相关文章推荐
- 自己动手实现一个队列LGQueue(刚刚)
- android 推送 mosquitto MQTT
- UIView之动画效果的实现方法(合集
- django @login_required
- 采用easyui tree编写简单角色权限代码的方法
- iOS-UI-02 UILabel UIButton
- ioS -UI-菜单栏的实现
- fifa 15 xbox one coins live quite feints
- PAT (Advanced Level) 1062. Talent and Virtue (25) 德才论,结构体排序
- [Jenkins] 执行SoapUI的task,设置邮件内容为HTML+CSS
- leetCode 96.Unique Binary Search Trees (唯一二叉搜索树) 解题思路和方法
- hdu 2734(Quicksum)
- iPad开发 - UIPopoverController控制器
- Android Studio finished with non-zero exit value 1
- ios 使用xib时,在UIScrollView中添建内容view时,使用约束的注意
- hdu 杭电1509 Windows Message Queue【优先队列】
- 高逼格UI-ASD(Android Support Design)
- 实现登录弹出窗口
- UIImageView 圆角设置
- pywinauto处理UI自动化