设置 tabBar 下面文字和图片颜色
2016-01-26 11:58
281 查看
设置 tabBar 下面文字和图片颜色
设置图片
1.统一设置
tabBarItem.image = XXimage
2.显示为图片原样
**设置--图片渲染模式为origin**
childViewController.tabBarItem.selectedImage = UIImage(named: "\(imageName)_selected")?.imageWithRenderingMode(.AlwaysOriginal)
设置文字和大小颜色
可以定制每一个自控制器的颜色tabBarItem.setTitleTextAttributes–传入一个字典(里面设置文字颜色和大小)childViewController.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.orangeColor()], forState: UIControlState.Selected)
tabBar 下面文字与对应的导航栏 title 文字设置
事例代码childViewController.title = title childViewController.navigationItem.title = title childViewController.tabBarItem.title = title
如果用上面一句就会设置成统一的文字
如果用下面两句,则可以实现 tabBar 文字与导航栏 title 不同
如果tabBar下面的 image 中包括文字,此时不需要 tabBar 显示文字
此时问题就是— image 会整体上移动*解决方法:调整 image 位置
设置图片的 imageInsets
//tabBarItem的 Insets top向上稍微移动就好 childViewController.tabBarItem.imageInsets = UIEdgeInsets(top: 5, left: 0, bottom: 0, right: 0)
相关文章推荐
- hdu 5282 Senior's String 两次dp
- 60行JavaScript俄罗斯方块
- Python生成器表达式
- Json数据的序列化与反序列化的三种经常用法介绍
- Android自定义组件ListPopWindow
- 【数据表格】-005-增删改查
- amfe手机淘宝前端团队 https://github.com/amfe
- URL短地址---实现方案收集
- 仿新浪微博手机客户端呼出菜单
- 关于竞品分析,这应该是最实用的分析流程
- 【HTML5】DOMContentLoaded事件
- 浏览器缓存相关HEADER头
- 三步走--低功耗蓝牙BLE开发实战
- jdk&jre FAQ
- 2016,开始用博客记录工作!
- head first设计模式(一)——策略模式
- swift 单例实现
- linux 问答
- 设计模式之我见
- 基于openfire+smack开发Android即时聊天应用[一]-用户注册、登陆、修改密码、注销等