Custom Font Support
Applications that want to use custom fonts can now include those fonts in their application bundle and register those fonts with the system by including the UIAppFonts key in their Info.plist file. The value of this key is an array of strings identifying the font files in the application’s bundle. When the system sees the key, it loads the specified fonts and makes them available to the application.
Once the fonts have been set in the Info.plist
, you can use your custom fonts as any other font in IB or programatically.
Info.plist
and add Fonts provided by application key
(UIAppFonts). Add font name as the value to the Item 0 key. Note: Font name can vary from your font file name.
[Swift 3]
for family in UIFont.familyNames {
print("\(family)")
for name in UIFont.fontNames(forFamilyName: family) {
print(" \(name)")
}
}
[Objective - C]
for (NSString *familyName in [UIFont familyNames]){
NSLog(@"Family name: %@", familyName);
for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) {
NSLog(@"--Font name: %@", fontName);
}
}