DEV Community

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

Posted on

1

[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

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay