I'm having a Xamarin.IOs project. I need to use dynamic type fonts in my application.
I have followed this tutorial in doing so. The tutorial is in in swift I guess. And for the code segment,
label.Font = UIFontMetrics(forTextStyle: .title1).ScaledFont(for: customFont)
in the tutorial, the equivalent Xamarin.IOs C# code is,
label.Font = UIFontMetrics.GetMetrics(textStyle: <string_value>).GetScaledFont(customFont);
But what are the values can I use for <string_value>
of textStyle
?
I have tried,
"title 1"
"title1"
".title1"
".title 1"
"UIFontTextStyleTitle1"
"PreferredTitle1"
but non helped.
What string values does UIFontMetrics.GetMetrics()
accept?
There are two ways to do this,
UIFontMetrics.GetMetrics(UIFontDescriptor.PreferredTitle1.TextStyle).GetScaledFont(customFont);
The text style's string values can be taken from the TextStyle
property of UIFontDescriptor
text style properties,
UIFontDescriptor.PreferredTitle1.TextStyle
UIFontMetrics.GetMetrics(UIFontTextStyle.Title1.GetConstant()).GetScaledFont(customFont);
The text style's string values can be taken from the GetConstant()
extension method of UIFontTextStyle
text style properties,
UIFontTextStyle.Title1.GetConstant()
One of these would be much better than entering string values directly 😊