When developing in swift 3 I was used to write:
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.orange]
putting this in AppDelegate would change all the UINavbars' title color to orange.
Now I want to do the same with Swift 4 and iOS 11.
let navigation = UINavigationBar. appearance() let navigationFont = UIFont(name: "Custom_Font_Name", size: 20) let navigationLargeFont = UIFont(name: "Custom_Font_Name", size: 34) //34 is Large Title size by default navigation. titleTextAttributes = [NSAttributedStringKey. foregroundColor: UIColor.
1: Select the "navigation item" from the document outline pane. 2: Open the attributes-inspector. 3: Select the title field and write the title here instead.
You can change the UINavigationBar title color by setting the foregroundColor
property on titleTextAttributes
.
As documented here:
The titleTextAttributes property specifies the attributes for displaying the bar’s title text. You can specify the font, text color, text shadow color, and text shadow offset for the title in the text attributes dictionary using the font , foregroundColor , and shadow keys, respectively.
So you will have the same effect doing this:
UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor.rawValue: UIColor.orange]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With