When I specified titleTextAttributes to change the text color of the iOS navigation bar, the font was broken, so I coped with it.
Xcode 11.3 iOS 14.0 & 13.3
If the font is specified in the navigation bar title, Even if only the color is specified, the font specification is not specified.
--If the font is Hiragino Kaku Gothic (with xib)
--If you want to change the color of the title on a specific screen and specify only the color as is often the case, the font specification will be removed (is it the system default?)
self.navigationController?.navigationBar.titleTextAttributes = [
//Text color
.foregroundColor: UIColor.yellow
]
↓
--You also need to add the font specification
self.navigationController?.navigationBar.titleTextAttributes = [
NSAttributedString.Key.foregroundColor: UIColor.yellow,
NSAttributedString.Key.font: UIFont(name: "HiraginoSans-W3", size: 16) as Any
]
↓
It's natural, but I didn't notice it, so I'll post it as a memorandum.
Recommended Posts