如何更改导航标题的颜色
How to change color of navigation title
我正在尝试更改导航标题的颜色。如何在不在 AppDelegate 文件的 didFinishLaunchingWithOptions 方法中更改导航标题的颜色。
var viewModel: SignUpViewModel? {
didSet {
viewModel?.viewDelegate = self
title = "Sign Up"
}
}
您可以通过设置标题文本属性来更改导航栏标题颜色
navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.blue]
您可以通过设置色调颜色来更改导航栏按钮的颜色
navigationController?.navigationBar.tintColor = UIColor.blue
public var navigationBarColor = UIColor() {
didSet {
UINavigationBar.appearance().barTintColor = UIColor(red: 234.0/255.0, green: 46.0/255.0, blue: 73.0/255.0, alpha: 1.0)
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key
.foregroundColor : UIColor.white]
}
}
我正在尝试更改导航标题的颜色。如何在不在 AppDelegate 文件的 didFinishLaunchingWithOptions 方法中更改导航标题的颜色。
var viewModel: SignUpViewModel? {
didSet {
viewModel?.viewDelegate = self
title = "Sign Up"
}
}
您可以通过设置标题文本属性来更改导航栏标题颜色
navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.blue]
您可以通过设置色调颜色来更改导航栏按钮的颜色
navigationController?.navigationBar.tintColor = UIColor.blue
public var navigationBarColor = UIColor() {
didSet {
UINavigationBar.appearance().barTintColor = UIColor(red: 234.0/255.0, green: 46.0/255.0, blue: 73.0/255.0, alpha: 1.0)
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key
.foregroundColor : UIColor.white]
}
}