Changing titleTextAttribute in swift

There was a recent change so that UIFont(name:size:) returns an optional UIFont instance. You'll need to unwrap them to get it to work. Using ! is the easiest way, but will get you a crash if the font isn't on the system. Try something like:

let navbarFont = UIFont(name: "Ubuntu", size: 17) ?? UIFont.systemFontOfSize(17)
let barbuttonFont = UIFont(name: "Ubuntu-Light", size: 15) ?? UIFont.systemFontOfSize(15)

UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName: navbarFont, NSForegroundColorAttributeName:UIColor.whiteColor()]
UIBarButtonItem.appearance().setTitleTextAttributes([NSFontAttributeName: barbuttonFont, NSForegroundColorAttributeName:UIColor.whiteColor()], forState: UIControlState.Normal)

Swift 4:

UIBarButtonItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor: UIColor.white], for: .normal)
UINavigationBar.appearance().titleTextAttributes = [
            NSAttributedStringKey.foregroundColor: UIColor.white
        ]

For Swift 3 you could try the following:

UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white]