在Xamarin.Forms中,我正在使用Label并尝试设置Font。
以下代码有效:
Label label1 = new Label();
label1.Font = Font.SystemFontOfSize(10);
但是尝试指定字体属性,例如:
Label label1 = new Label();
label1.Font = Font.SystemFontOfSize(10, FontAttributes.Bold);
正在阻止ContentPage呈现异常。
有一个Font.BoldSystemFontOfSize()可以使用,但是这是不推荐使用的,所以我现在尝试使用Font.SystemOfSize代替。
如何使用此功能?
这是在我的项目中工作的一段代码:
new Label {
Text = "text goes here",
Font = Font.SystemFontOfSize (NamedSize.Medium)
.WithAttributes (FontAttributes.Bold),
}
这使您不必指定特定的字体大小,而是使用默认用于标签的字体大小
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句