在Xamarin.forms中Label的部分文本属性中应用斜体效果
本文关键字:应用 属性 斜体 文本 forms Xamarin Label | 更新日期: 2023-09-27 18:02:16
这是我在Xamarin.forms中的代码片段。
grid.Children.Add (new Label {Text = "Italic, Bold",
XAlign = TextAlignment.Center,
YAlign = TextAlignment.Center,
FontSize = 30
}, 1, 1);
我需要设置"Italic"为斜体,加粗" bold "
有人能帮我吗?
我解决了。
var fs = new FormattedString ();
fs.Spans.Add (new Span { Text="Italic", ForegroundColor = Color.Gray, FontSize = 20, FontAttributes = FontAttributes.Italic });
fs.Spans.Add (new Span { Text=", Bold", ForegroundColor = Color.Gray, FontSize = 20, FontAttributes = FontAttributes.Bold });
labelFormatted.FormattedText = fs;