I downloaded a cool font, and want to use it as the nav bar title for my app, but can't seem to get the app to recognize/display it. An exception is thrown every run attempt. Here are the steps I took.
myCustomFont.ttf
file into the project as I do other supporting files (images, etc.)info.plist
file by adding Font provided by application
, and adding the name of the file to the arrayAppDelegate.swift
// Navigation bar customization
let navigationController = window!.rootViewController as UINavigationController
navigationController.navigationBar.titleTextAttributes = [NSFontAttributeName : (UIFont(name: "myCustomFont", size: 10))!]
The above code works if I replace myfont
with something standard like Times New Roman
or Arial
.
Any help would be much appreciated. Thanks!
Be sure your font is in Bundle Resources. For some reason Xcode it is not importing custom font properly most of the time:
and try this in the AppDelegate
UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName : UIFont(name: "JennaSue", size: 20)!, NSForegroundColorAttributeName : uicolorFromHex(0x5C8CA7)]