For this example I will be adding Montserrat-Bold and Montserrat-Regular as custom font to my iOS app
Steps
Download the font files, Montserrat
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
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
}
Top comments (0)