I have a multiple View Controllers and I want to set the font color of all to red.
[[UINavigationBar appearance] setFont:[UIFont boldSystemFontOfSize:12.0]]
If you need to do this in Swift, you can create an extension for the UINavigationBar to allow you to get or set these settings.
extension UINavigationBar {
var titleColor: UIColor? {
get {
if let attributes = self.titleTextAttributes {
return attributes[NSForegroundColorAttributeName] as? UIColor
}
return nil
}
set {
if let value = newValue {
self.titleTextAttributes = [NSForegroundColorAttributeName: value]
}
}
}
var titleFont: UIFont? {
get {
if let attributes = self.titleTextAttributes {
return attributes[NSFontAttributeName] as? UIFont
}
return nil
}
set {
if let value = newValue {
self.titleTextAttributes = [NSFontAttributeName: value]
}
}
}
}
You can then set the color and font like this:
navigationBar.titleColor = UIColor.redColor()
navigationBar.titleFont = UIFont.systemFontOfSize(12)