iOS7修改UITabBar文本颜色以及解决自定义选中图片显示为默认蓝色的问题
来源:互联网 发布:一起走软件登录 编辑:程序博客网 时间:2024/06/09 22:54
修改UITabbar背景色和文本颜色和大小:
[[UITabBar appearance] setBackgroundColor:UIColorFromRGB(0xeff3f4)]; [[UITabBarItem appearance] setTitleTextAttributes:@{ NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue" size:12.5f], NSForegroundColorAttributeName : UIColorFromRGB(0x929292) } forState:UIControlStateNormal]; [[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : UIColorFromRGB(0xFF87C332) } forState:UIControlStateSelected];
解决自定义选中图片显示为默认蓝色的问题:
在iOS7以上的手机中,第一个Tab的选中图一直显示的是系统默认的蓝色图,查看了一下UITabItem的头文件,发现下面的内容:
/* The unselected image is autogenerated from the image argument. The selected image is autogenerated from the selectedImage if provided and the image argument otherwise. To prevent system coloring, provide images with UIImageRenderingModeAlwaysOriginal (see UIImage.h) */- (instancetype)initWithTitle:(NSString *)title image:(UIImage *)image tag:(NSInteger)tag;- (instancetype)initWithTitle:(NSString *)title image:(UIImage *)image selectedImage:(UIImage *)selectedImage NS_AVAILABLE_IOS(7_0);- (instancetype)initWithTabBarSystemItem:(UITabBarSystemItem)systemItem tag:(NSInteger)tag;
意思是,如果不希望使用系统颜色,需要对图片加上属性UIImageRenderingModeAlwaysOriginal
所以按此方式实验,代码如下:
UIImage *iconImage = [UIImage imageNamed:@"icon.png"];UIImage *iconImageSel = [UIImage imageNamed:@"icon_selected.png"];iconImage = [iconImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];iconImageSel = [iconImageSel imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];self.musicViewController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Music" image: iconImage selectedImage: iconImageSel];
0 0
- iOS7修改UITabBar文本颜色以及解决自定义选中图片显示为默认蓝色的问题
- iOS7 UITabBar自定义选中图片显示为默认蓝色的Bug
- iOS7 UITabBar自定义选中图片显示为默认蓝色的Bug
- iOS7 UITabBar自定义选中图片显示为默认蓝色的Bug
- [iOS]iOS7+ UITabBar修改选中图片显示为默认蓝色的问题解决方法,去除UITabbar顶部一像素横线
- OS7 UITabBar自定义选中图片显示为默认蓝色的Bug
- iOS 解决UITabBarItem选中图片默认为蓝色的方法
- Swift之修改选中TabBarItem图片时显示的默认蓝色
- UITabbar系统默认蓝色修改
- iOS 设置UITabBar,背景颜色,默认图片,文字颜色,和选中颜色.
- IOS 7修改UITabbar背景图片、UITabBarItem图片以及UITabBarItem的文字颜色.
- UITabBar-UITabBarItem的选中图片未按照原图样式显示的问题mark
- 解决iOS8以上系统下app底部UITabBarItem上自定义的背景色和图片,在首次启动或push之后再pop回去会变成系统默认颜色-蓝色问题
- UITabBar背景、icon图标颜色、被选中背景设置以及隐藏UITabBar的方式
- 关于UITabBar 显示图片的问题
- 修改元素文本的默认选中样式
- IOS7怎么修改Navigation Bar上的返回按钮文本颜色,箭头颜色以及导航栏按钮的颜色
- IOS7怎么修改Navigation Bar上的返回按钮文本颜色,箭头颜色以及导航栏按钮的颜色
- Shell学习if判断字符串
- java观察者模式及实现例子
- 幂和阶乘 UVa10780
- jsp格式化字符串
- BZOJ 1097 [POI2007]旅游景点atr
- iOS7修改UITabBar文本颜色以及解决自定义选中图片显示为默认蓝色的问题
- nginx网络服务器上如何阻止特定用户代理(UA)
- Spring 之注解事务 @Transactional
- php学习之 基础一
- HTML学习笔记
- SDUT 2278----商人的诀窍
- handler和实现接口的方式实现按钮的点击功能
- MPEG-2 TS码流分析
- 遍历Map的四种方法