Gen*_*ure 10 ios swift swiftui
我有使用自定义参数定义的字体:
public var suiFont: Font {
.custom(name, size: size)
}
Run Code Online (Sandbox Code Playgroud)
然后我需要使用它们来创建UIKit's UIFont。如何从Font结构体中获取参数?我找到了标准字体的解决方案:
UIFont.preferredFont(forTextStyle: .body).pointSize
UIFont.preferredFont(forTextStyle: .body).fontName
UIFont.preferredFont(forTextStyle: .body).fontDescriptor
Run Code Online (Sandbox Code Playgroud)
但它不适合我的情况,因为我的字体是使用自定义参数创建的。例如Font.custom("SFUI", size: 25)返回尺寸 17。
还有其他方法可以从 SwiftUI Font 获取字体参数吗?标准 SwiftUI 元素如何使用包装的 UIKit 元素来做到这一点?
| 归档时间: |
|
| 查看次数: |
3512 次 |
| 最近记录: |