我正在修改 LaunchScreen.storyboard 文件。我想在其中的标签中使用自定义字体。我的字体是 .fft 类型。我无法将 IBOutlet 创建为视图控制器,因为启动屏幕不能是 UIViewController 的子类。
那么如何在LaunchScreen.storyboard文件中使用自定义字体呢?
您无法在启动屏幕上使用自定义字体。仅标准系统字体。
系统会在运行时自动替换您的自定义字体到系统。
对于 swiftUI 来说还是这样吗? 我在我的项目中添加了一个新的启动屏幕 -将字体安装到系统字体簿中并在文本编辑中使用 -将字体添加到自定义目标 iso 属性 -> 应用程序提供的字体 -将字体添加到项目复制并将其添加到文件夹和目标中 - 运行以下代码并打印字体 - 能够在预览中看到字体 - 重新启动 Mac 和 Xcode -更改了字体颜色
// I see the font name and can use it in the ContentView but not the launch screen attribute inspector -> custom -> [select custom .ttf font here]
init() {
for familyName in UIFont.familyNames {
print(familyName)
for fontName in UIFont.fontNames(forFamilyName: familyName){
print("--\(fontName)")
}
}
}