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.
- I moved the
myCustomFont.ttf
file into the project as I do other supporting files (images, etc.) - Updated my
info.plist
file by addingFont provided by application
, and adding the name of the file to the array - Then, I added the following code to
AppDelegate.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