Mak*_*ich 7 xamarin xamarin.forms
更新到iOS 13后,我的字体失败了。在我的App.xaml中,我有:
<OnPlatform x:Key="FontFamilyRegular" x:TypeArguments="x:String">
<On Platform="iOS">.SFUIText</On>
</OnPlatform>
<OnPlatform x:Key="FontFamilyMedium" x:TypeArguments="x:String">
<On Platform="iOS">.SFUIText-Medium</On>
</OnPlatform>
<OnPlatform x:Key="FontFamilyBold" x:TypeArguments="x:String">
<On Platform="iOS">.SFUIText-Semibold</On>
</OnPlatform>
Run Code Online (Sandbox Code Playgroud)
一切正常,直到我将设备更新到iOS 13。
我调试了iOS项目,发现字体名称可以更改为:.SFUI-Regular,.SFUI-Semibold-但这些都不起作用。我也尝试更新到最新的Xamarin版本-祝您好运。
如何在最新的iOS版本中使用这3种字体系列?
像这样的系统字体现在可以使用“点”/.符号引用,如下所示:
https://developer.apple.com/videos/play/wwdc2019/227/
与iOS 13开始,您可以利用新的枚举UIFontDescriptor.SystemDesign,使用regular,rounded,serif或monospaced。
如何在 Swift 中使用描述符创建字体的示例(请参阅我如何使用design参数):
extension UIFont {
convenience init?(
style: UIFont.TextStyle,
weight: UIFont.Weight = .regular,
design: UIFontDescriptor.SystemDesign = .default) {
guard let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: style)
.addingAttributes([UIFontDescriptor.AttributeName.traits: [UIFontDescriptor.TraitKey.weight: weight]])
.withDesign(design) else {
return nil
}
self.init(descriptor: descriptor, size: 0)
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1023 次 |
| 最近记录: |