定制UITabbar样式
2015-09-22 14:43
429 查看
1、背景颜色
2、顶部阴影线,新建UITabbar扩展类
3、选中项颜色
4、默认图标,使用原图
5、标题样式修改,还可定制其他属性,参考NSAttributedString.h
_tabbar.barTintColor = [UIColor blueColor];
2、顶部阴影线,新建UITabbar扩展类
- (void)layoutSubviews { [super layoutSubviews]; if (self.shadowColor) { self.topLineView.backgroundColor = self.shadowColor; } } - (UIView *)topLineView { UIView *view = nil; for (UIView *subview in self.subviews) { if (subview.top < 0 && [subview isKindOfClass:[UIImageView class]]) { view = subview; break; } } return view; }
3、选中项颜色
_tabbar.selectedImageTintColor = [UIColor redColor];
4、默认图标,使用原图
UIImage *selectedImage = [UIImage imageNamed:@"menu_home"]; UIImage *defaultImage = [selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; UITabBarItem *item1 = [[UITabBarItem alloc] initWithTitle:@"首页" image:defaultImage selectedImage:selectedImage];
5、标题样式修改,还可定制其他属性,参考NSAttributedString.h
+ (void)load { NSDictionary *attributes = @{ NSForegroundColorAttributeName: [UIColor colorWithHexValue:0xaeaeae] }; [[UITabBarItem appearance] setTitleTextAttributes:attributes forState:UIControlStateNormal]; attributes = @{ NSForegroundColorAttributeName: [UIColor colorWithHexValue:0xff8eba] }; [[UITabBarItem appearance] setTitleTextAttributes:attributes forState:UIControlStateSelected]; }
相关文章推荐
- java学习笔记StringBuffer/StringBuilder及基本数据类型
- proxy-target-class="true" 与proxy-target-class="false"的区别
- Ueditor结合七牛云及百度云存储(JAVA版,ueditor-1.4.3)实现图片文件上传
- 小米MIUI的发送彩信(MMS)的权限研究
- UEditor在线编辑器配置及注意事项
- UIBarButtonItem变弹簧
- UIAutomator环境配置
- UI24_NSUserDefaults
- ubuntu14.04禁用guest用户登录
- ueditor1_4_3-utf8-jsp 配置实现上传图片的功能
- ElasticSearch源码分析之一:使用Guice进行依赖注入与模块化系统
- 关于获取text类型value的一个小问题
- IOS UICollectionView学习
- UIImagePickerController 中文
- 解决valgrind线程数不够的错误:no free slots available Increase VG_N_THREADS, rebuild and try again.
- 带填充间距的 UILabel 在项目中的使用
- 使用UIPickerView实现弹出提示框
- 自定义UILabel UITextField 填充
- IOS开发之UIScrollView控件详解
- JMS Topic 和queue 的区别