Correctly using custom fonts in XCode
There are several steps needed before you can successfully use your custom fonts in your iOS app.
Step 1:
Drag your fonts into XCode project, and make sure each of them is included in the target
Step 2:
Double check that your fonts are in the Resource Bundle
Select your target -> Build Phases -> Copy Bundle Resources
Step 3:
Add your fonts to application plist
Step 4:
Check the fonts names
The font file downloaded from internet might be differ from the font name itself. You can check the font name with following codes:
Objective-C
1 | for (NSString * fontFamilyName in UIFont.familyNames) { |
Swift1
2
3
4for family in UIFont.familyNames.sorted() {
let names = UIFont.fontNames(forFamilyName: family)
print("Family: \(family) Font names: \(names)")
}
Step 5:
Finally, use your custom fonts.