在iOS8系统下,UITabbar上的item自定义背景色和图片问题
2016-03-03 13:45
423 查看
http://blog.sina.com.cn/s/blog_64cfe8f00102v0yn.html
在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"]];
在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"]];
相关文章推荐
- 自己CA脚本
- kubernetes集群中部署kube-ui
- Android showDialog时报错requestFeature() must be called before adding content
- iOS基础--UIView的常见属性
- @FormParam、@PathParam、@QueryParam、@HeaderParam、@CookieParam、@MatrixParam说明
- mybatis 关于 Parameter Maps collection does not contain value for
- UIFont字体大全
- ios开发——解决UICollectionView的cell间距与设置不符问题
- LeetCode Unique Word Abbreviation
- 解决uitableviewcell重绘出现重叠的现象
- Implement Queue by Two Stacks
- spoj SORTBIT - Sorted bit squence
- Request获取用户真实IP
- iOS-UUID和UDID
- input propertychange事件,当input的value值发生改变时触发(文本框的值即时搜索)
- storyboard代码根据segue 跳转
- 手机实现拨号功能,
- easyui表头标题列扭曲
- 我的第一个博客&GuiHub简单练习
- Home Screen Quick Actions