UITabbar 中的 item的字体颜色 item点击后的tint颜色 和图片颜色的修改
来源:互联网 发布:淘宝免费模板 编辑:程序博客网 时间:2024/05/01 17:42
这个问题解决了有些时候了,终于知道了办法,先看个代码
[UITabBar appearance] setTintColor:[UIColor colorWithRed:0.0
green:176.0/255.0 blue:226.0/255.0 alpha:1.0]; [UITabBarItem
appearance] setTitleTextAttributes:[NSDictionary
dictionaryWithObjectsAndKeys: [UIColor lightGrayColor],
UITextAttributeTextColor, nil] forState:UIControlStateNormal];
UITabbar有个setTintColor这个方法,可以理解为,高亮的时候,或者点击后的颜色设置。
UITabBarItem有个setTitleTextAttributes的方法,是用来设置字体的颜色。
我这里是在viewDidLoad添加的。
代码如下:
//设置tabbar的背景图片 UITabBar *tabBar = self.tabBarController.tabBar; [tabBar
setTintColor:[UIColor colorWithRed:0.0 green:176.0/255.0
blue:226.0/255.0 alpha:1.0]; tabBar.selectedImageTintColor = [UIColor
clearColor]; UITabBarItem *item = [tabBar.items objectAtIndex:0];
NSString *homePath = [NSBundle mainBundle]
pathForResource:@"btn_home_highlight" ofType:@"png"]; if(item.tag == 1)
{ [item setTitleTextAttributes:[NSDictionary
dictionaryWithObjectsAndKeys: [UIColor lightGrayColor],
UITextAttributeTextColor, nil] forState:UIControlStateNormal];
item.selectedImage = [UIImage imageWithContentsOfFile:homePath]; }
green:176.0/255.0 blue:226.0/255.0 alpha:1.0]; [UITabBarItem
appearance] setTitleTextAttributes:[NSDictionary
dictionaryWithObjectsAndKeys: [UIColor lightGrayColor],
UITextAttributeTextColor, nil] forState:UIControlStateNormal];
UITabbar有个setTintColor这个方法,可以理解为,高亮的时候,或者点击后的颜色设置。
UITabBarItem有个setTitleTextAttributes的方法,是用来设置字体的颜色。
我这里是在viewDidLoad添加的。
代码如下:
//设置tabbar的背景图片 UITabBar *tabBar = self.tabBarController.tabBar; [tabBar
setTintColor:[UIColor colorWithRed:0.0 green:176.0/255.0
blue:226.0/255.0 alpha:1.0]; tabBar.selectedImageTintColor = [UIColor
clearColor]; UITabBarItem *item = [tabBar.items objectAtIndex:0];
NSString *homePath = [NSBundle mainBundle]
pathForResource:@"btn_home_highlight" ofType:@"png"]; if(item.tag == 1)
{ [item setTitleTextAttributes:[NSDictionary
dictionaryWithObjectsAndKeys: [UIColor lightGrayColor],
UITextAttributeTextColor, nil] forState:UIControlStateNormal];
item.selectedImage = [UIImage imageWithContentsOfFile:homePath]; }
0 0
- UITabbar 中的 item的字体颜色 item点击后的tint颜色 和图片颜色的修改 UINavigationBar字体设置
- UITabbar 中的 item的字体颜色 item点击后的tint颜色 和图片颜色的修改
- ToolBar修改menu item的字体颜色
- ToolBar修改menu item的字体颜色
- Main.storyboard 和 如何修改Tab bar item 的图片、字体颜色 -
- 动态改变Listview的item背景颜色和item中字体的颜色
- ListView点击后item的颜色不变色
- ListView点击后改变item颜色的Demo
- iOS 设置tabBar点击后Item的背景颜色.
- 改变item的颜色
- 实现listview条目点击后改变item背景颜色和字体颜色并保留
- ListView中的Button点击后相应的Item改变背景颜色
- 修改NavigationView的MenuItem的字体颜色并修改默认选中的item
- 修改NavigationView的MenuItem的字体颜色并修改默认选中的item
- [Android]取消GridView点击item时的颜色(我的手机点击后是橙黄色)
- 设置uitabbar里的字体颜色
- HTML中设置超链接字体颜色和点击后的字体颜色的方法
- listview 点击 item 字体变颜色
- 怎么干翻大众点评
- 二分实现
- Nexus 教程
- int const *p \ const int *p \ const int * const p 解析
- 批量更改文件后缀
- UITabbar 中的 item的字体颜色 item点击后的tint颜色 和图片颜色的修改
- 树状数组的大概理解
- Java实现双链表
- C++ Primer Plus学习笔记:第二章
- pku 1845
- 让footer固定在对底端的两种方式
- 2014新生暑假个人排位赛02
- linux 系统crunchbang的安装
- JavaLearning:单例设计模式