I used this code
self.navigationController?.navigationBar.titleTextAttributes =
[NSFontAttributeName: UIFont(name: "HelveticaNeue-Light", size: 20),
NSForegroundColorAttributeName: UIColor.whiteColor()]
and I'm getting error "Could not find an overload for “init” that accepts the supplied arguments"
UIFont(name:size:)
is now a failable initializer -- it will return nil
if it can't find that font and crash your app if you unwrap the return value. Use this code to safely get the font and use it:
if let font = UIFont(name: "HelveticaNeue-Light", size: 20) {
self.navigationController?.navigationBar.titleTextAttributes =
[NSFontAttributeName: font,
NSForegroundColorAttributeName: UIColor.whiteColor()]
}
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