[Xcode] Add a custom font to iOS app

Lucien·2022년 8월 11일

1. Add the font file to your project file

.ttf, .otf both are fine. Make sure font file is a target member of your app.

2. Register Your Font File with iOS

Add the key "Fonts provided by application" to Info.plist. Value must include file extension as well.

3. Use your custom font in source code

struct FontManager {
    struct Nexa {
        static let bold = "Nexa Bold"
        static let textBold = "NexaTextDemo-Bold"
        static let textLight = "NexaTextDemo-Light"
    }
}
Text("Type something")
    .font(.custom(FontManager.Nexa.bold, size: 16))

Source: https://developer.apple.com/documentation/uikit/text_display_and_fonts/adding_a_custom_font_to_your_app

0개의 댓글