DEV Community

Cover image for [iOS Swift] - Adding Custom Fonts to your app
Mark Matute
Mark Matute

Posted on

[iOS Swift] - Adding Custom Fonts to your app

For this example I will be adding Montserrat-Bold and Montserrat-Regular as custom font to my iOS app


Steps

  1. Download the font files, Montserrat

  2. Create directory Fonts and drag-n-drop the files to the directory, and on the pop up make sure to check copy files if needed

  3. Register the custom fonts on Info.plist
    Info.plist

  4. Using the custom fonts on storyboards
    Selecting font on storyboard

  5. Using the custom fonts on code



public static func montserratRegular(fontSize: CGFloat) -> UIFont {
        guard let customFont = UIFont(name: "Montserrat-Regular", size: fontSize) else {
            fatalError("""
                Failed to load the "Montserrat-Regular" font.
                Make sure the font file is included in the project and the font name is spelled correctly.
                """
            )
        }
        return customFont
    }


Enter fullscreen mode Exit fullscreen mode

Disclaimer

Disclaimer

Top comments (0)