gpt4 book ai didi

xamarin.forms - 如何将Xamarin.Forms标签字体设置为粗体

转载 作者:行者123 更新时间:2023-12-03 13:20:54 24 4
gpt4 key购买 nike

Xamarin.Forms 中,我正在使用标签并尝试设置字体

以下代码有效:

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),
}

这使您不必指定特定的字体大小,而是使用默认用于标签的字体大小

关于xamarin.forms - 如何将Xamarin.Forms标签字体设置为粗体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25085431/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com