为了更改所有视图控制器的导航栏颜色,您必须在AppDelegate.swift文件中设置它
添加以下代码以didFinishLaunchingWithOptions使其起作用AppDelegate.swift
var navigationBarAppearace = UINavigationBar.appearance()
navigationBarAppearace.tintColor = uicolorFromHex(0xffffff)
navigationBarAppearace.barTintColor = uicolorFromHex(0x034517)
Run Code Online (Sandbox Code Playgroud)
在此tintColor属性中更改导航栏的背景颜色。
barTintColor属性对颜色的影响:
奖金:
更改导航栏标题的颜色:
// change navigation item title color
navigationBarAppearace.titleTextAttributes =[NSForegroundColorAttributeName:UIColor.whiteColor()]
Run Code Online (Sandbox Code Playgroud)
titleTextAttributes影响标题文本
我希望它有帮助。:)
| 归档时间: |
|
| 查看次数: |
10908 次 |
| 最近记录: |