如何在swiftui中添加自定义字体?

如何在swiftui中添加自定义字体?,swiftui,custom-font,Swiftui,Custom Font,我想在我的swift ui游戏中添加自定义字体。有人知道怎么做吗?我试图观看youtube视频,但找不到任何好的视频。将自定义字体添加到项目中,并在.plist中注册 然后定义 extension Font { struct Event { let name = Font.custom("GillSans-UltraBold", size: 14) let location = Font.custom("GillSans-S

我想在我的swift ui游戏中添加自定义字体。有人知道怎么做吗?我试图观看youtube视频,但找不到任何好的视频。

将自定义字体添加到项目中,并在.plist中注册

然后定义

extension Font {
    struct Event {
        let name = Font.custom("GillSans-UltraBold", size: 14)
        let location = Font.custom("GillSans-SemiBold", size: 10)
        let date = Font.custom("GillSans-UltraBold", size: 16)
        let price = Font.custom("GillSans-SemiBoldItalic", size: 12)
    }
    static let event = Event()
}
用法示例:

Text("iPhone 12 Pro Super Max").font(Font.event.name)

这回答了你的问题吗?