如何在 swiftui 中添加自定义字体?
How do I add custom fonts in swiftui?
我想为我的 swift ui 游戏添加自定义字体。有谁知道这是怎么做到的吗?我试着看了一个 youtube 视频,但我找不到任何好的视频。
将自定义字体添加到您的项目并在 .plist
中注册
https://developer.apple.com/documentation/uikit/text_display_and_fonts/adding_a_custom_font_to_your_app
然后定义
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)
我想为我的 swift ui 游戏添加自定义字体。有谁知道这是怎么做到的吗?我试着看了一个 youtube 视频,但我找不到任何好的视频。
将自定义字体添加到您的项目并在 .plist
中注册
https://developer.apple.com/documentation/uikit/text_display_and_fonts/adding_a_custom_font_to_your_app
然后定义
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)