Reputation: 3670
I am using this code to change the navigation bar color and font. How do i make the font thin? I tried adding a font family name, but the app crashed. Please answer in swift.
nav?.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor(), NSFontAttributeName: UIFont.boldSystemFontOfSize(20)]
Upvotes: 0
Views: 84
Reputation: 6824
Please take a look at your own code, bold is the opposite to thin.
When you state UIFont.boldSystemFontOfSize(20)]
you're telling UIKit to use the default Font with a thick format.
UPDATE:
Use one of these functions instead:
UIFont.systemFontOfSize(fontSize: CGFloat, weight: CGFloat)
UIFont.systemFontOfSize(fontSize: CGFloat)
Upvotes: 0
Reputation: 9356
use this code :
self.navigationController.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "CaviarDreams", size: 20)!]
let colorDict: NSDictionary = [NSForegroundColorAttributeName: UIColor.whiteColor()]
self.navigationController.navigationBar.titleTextAttributes = colorDict
Upvotes: 2