I am attempting to change the color of a navigation title. How can I change the color of a navigation title without doing it in the didFinishLaunchingWithOptions method in the AppDelegate file.
var viewModel: SignUpViewModel? {
didSet {
viewModel?.viewDelegate = self
title = "Sign Up"
}
}
CodePudding user response:
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]
}
}
CodePudding user response:
you can change the navigation bar title color by setting title text attributes
navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.blue]
you can change the navigation bar buttons color by setting tint color
navigationController?.navigationBar.tintColor = UIColor.blue