Xamarin IOs,要传递给 textStyle 参数的 UIFontMetrics.GetMetrics 方法的字符串值是什么?
Xamarin IOs, What are the string values to pass into UIFontMetrics.GetMetrics method for the textStyle parameter?
我有一个 Xamarin.IOs 项目。我需要在我的应用程序中使用动态字体。
我已经按照 this tutorial 这样做了。我猜教程在 swift 中。而对于代码段,
label.Font = UIFontMetrics(forTextStyle: .title1).ScaledFont(for: customFont)
在教程中,等效的 Xamarin.IOs C# 代码是,
label.Font = UIFontMetrics.GetMetrics(textStyle: <string_value>).GetScaledFont(customFont);
但是 textStyle
的 <string_value>
可以使用哪些值?
我试过了,
"title 1"
"title1"
".title1"
".title 1"
"UIFontTextStyleTitle1"
"PreferredTitle1"
但没有帮助。
UIFontMetrics.GetMetrics()
接受哪些字符串值?
有两种方法可以做到这一点,
方式一:
UIFontMetrics.GetMetrics(UIFontDescriptor.PreferredTitle1.TextStyle).GetScaledFont(customFont);
文本样式的字符串值可以从 UIFontDescriptor
文本样式属性的 TextStyle
属性 中获取,
UIFontDescriptor.PreferredTitle1.TextStyle
方式二:
UIFontMetrics.GetMetrics(UIFontTextStyle.Title1.GetConstant()).GetScaledFont(customFont);
文本样式的字符串值可以从 UIFontTextStyle
文本样式属性的 GetConstant()
扩展方法中获取,
UIFontTextStyle.Title1.GetConstant()
其中一个比直接输入字符串值要好得多
我有一个 Xamarin.IOs 项目。我需要在我的应用程序中使用动态字体。
我已经按照 this tutorial 这样做了。我猜教程在 swift 中。而对于代码段,
label.Font = UIFontMetrics(forTextStyle: .title1).ScaledFont(for: customFont)
在教程中,等效的 Xamarin.IOs C# 代码是,
label.Font = UIFontMetrics.GetMetrics(textStyle: <string_value>).GetScaledFont(customFont);
但是 textStyle
的 <string_value>
可以使用哪些值?
我试过了,
"title 1"
"title1"
".title1"
".title 1"
"UIFontTextStyleTitle1"
"PreferredTitle1"
但没有帮助。
UIFontMetrics.GetMetrics()
接受哪些字符串值?
有两种方法可以做到这一点,
方式一:
UIFontMetrics.GetMetrics(UIFontDescriptor.PreferredTitle1.TextStyle).GetScaledFont(customFont);
文本样式的字符串值可以从 UIFontDescriptor
文本样式属性的 TextStyle
属性 中获取,
UIFontDescriptor.PreferredTitle1.TextStyle
方式二:
UIFontMetrics.GetMetrics(UIFontTextStyle.Title1.GetConstant()).GetScaledFont(customFont);
文本样式的字符串值可以从 UIFontTextStyle
文本样式属性的 GetConstant()
扩展方法中获取,
UIFontTextStyle.Title1.GetConstant()
其中一个比直接输入字符串值要好得多