swift 设置navigationBar的背景颜色和字体颜色
2016-03-14 10:27
471 查看
设置navigationBar中的背景颜色、字体颜色、字体大小。
在appdelegate文件中
1、设置背景颜色:
UINavigationBar.appearance().barTintColor = UIColor(red: 0.0/255.0, green:122.0/255.0, blue: 204.0/255.0, alpha: 1.0)
2、设置字体颜色:
UINavigationBar.appearance().tintColor = UIColor.whiteColor()
3、设置字体大小和颜色
if let barFont = UIFont(name: "Avenir-Light", size: 18.0) {
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor(), NSFontAttributeName: barFont]
}
在appdelegate文件中
1、设置背景颜色:
UINavigationBar.appearance().barTintColor = UIColor(red: 0.0/255.0, green:122.0/255.0, blue: 204.0/255.0, alpha: 1.0)
2、设置字体颜色:
UINavigationBar.appearance().tintColor = UIColor.whiteColor()
3、设置字体大小和颜色
if let barFont = UIFont(name: "Avenir-Light", size: 18.0) {
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor(), NSFontAttributeName: barFont]
}
相关文章推荐
- Swift 第三方库 - Alamofire
- swift 设置statusBar的文字颜色
- Swift 第三方库 - SnapKit
- swift - lazy load
- Swift中的柯里化函数
- 从Java到Swift
- Swift入门-Day 1
- Swift之一步一步带你封装一个本地缓存库
- Ubuntu 15.10安装Swift
- swift 之xib自定义view可视化到storyboard
- Swift 2.0 单例的用法
- 在Swift中使用JavaScript的方法和技巧
- 对照Java学习Swift--基础部分
- IOS·Swift 集合类型之字典类型排序
- Swift-predecessor(), successor(), advancedBy()
- swift 2.0改变的部分
- [译]raywenderlich.com官方的swift风格指南(二)
- [译]raywenderlich.com官方的swift风格指南(一)
- Swift语言工厂设计模式和抽象工厂设计模式
- 15--swift之内存管理