Adding a Custom Font to Your IOS App (Swift 5, Xcode 12, iOS 2021) - iOS Development 2021

In this Xcode tutorial, I discuss the topic of adding a custom font to your iOS app and use it in your app’s interface.

Import font files to Xcode project:


Register Your Font File into Info .plist file :


Open the info.plist file and add a new property named ‘Fonts provided by application’. The raw key of this property is UIAppFonts.When the property is added, the property ‘Fonts provided by application’ key is an Array type and add new items to the array, one for each font file you imported. Names of the items should match imported font file names.


Use Your Custom Font in Source Code:


You can find out what other fonts are already available to use in your app on iOS by running the following code which prints out all the font names.

      for fontFamily in UIFont.familyNames {
            for fontName in UIFont.fontNames(forFamilyName: fontFamily) {
                print("\(fontName)")
            }
        }

---------------

Use Code in helper class:


Easy to use:

 
@IBOutlet weak var lblName: UILabel!

override func viewDidLoad() {
    super.viewDidLoad()
    lblName.font = UIFont.poppinsSemiBold(size: 14)
}



Related tutorials:

Post a Comment

0 Comments