2015-07-11 53 views
7

這是我在Xamarin.forms中的代碼片段。在Xamarin的Label屬性部分中應用斜體效果.forms

grid.Children.Add (new Label {Text = "Italic, Bold", 
          XAlign = TextAlignment.Center, 
          YAlign = TextAlignment.Center, 
          FontSize = 30 
         }, 1, 1); 

我需要使「斜體」斜體字體和粗體「粗體」。

任何人都可以幫助我嗎?

回答

7

我解決了它。

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;