How to add custom font to iOS app in Xcode
You can add True Type Font (.ttf) or Open Type Font (.otf) to your app and use it the same way you use font provided by iOS.
Add your font file to your Xcode project
From menu bar select File->Add Files to “project_name” or just drag font files to your project
And make sure your font is a target member of your app in “Target membership” section
Register your font with iOS
iOS need to know about the new fonts, so open info.plist and add that key “Fonts provided by application” (its raw name is UIApp
Xcode will create an array for that key. Add every new font file name (including the extension) as an item to that array.
Using your custom font in Interface Builder
Now if you select a label for example from Interface Builder and select Font -> custom from “Attributes inspector” you will find your custom font in the list
Using custom font in code
To use your font in code you must first know its name (not the font file name)
Run this for-loop anywhere in your app to print a list of available fonts
for family in UIFont.familyNames.sorted() { let names = UIFont.fontNames(forFamilyName: family) print("Family: \(family) Font names: \(names)") }
Result:
Once you located your font name we can create instance of UIFont class to use it:
if let myFont = UIFont.init(name: "FuturaCE-Book", size: 12) { lblTitle.font = myFont }
and don’t forget to remove the for-loop code
Learn how to create custom controls in Interface Builder using @IBDesignable and @IBInspectable