【发布时间】:2016-12-21 15:59:49
【问题描述】:
在我的应用委托中,我调用以下代码将每个 VC 的导航栏颜色设置为蓝色。但是,如果用户没有登录并且只是在试用该应用程序,我希望导航栏为红色。
UINavigationBar.appearance().barTintColor = UIColor(red: 108.0/255.0, green: 158.0/255.0, blue: 236.0/255.0, alpha: 1.0) // Blue
// UINavigationBar.appearance().barTintColor = UIColor(red: 239.0/255.0, green: 119.0/255.0, blue: 97.0/255.0, alpha: 1.0) // Red
UINavigationBar.appearance().tintColor = .white
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white]
我将如何根据用户对每个 VC 的选择来更改颜色?
【问题讨论】:
-
检查您的应用代理是否已登录
-
在每个 VC 中调用这个
navigationController?.navigationBar.barTintColor = UIColor.blue -
如果有任何问题请告诉我
-
我认为您的意思是“导航栏控制器色调颜色”
标签: ios swift uinavigationbar