Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apply italic effect in the part of Text property of Label in Xamarin.forms

This is my snippet in Xamarin.forms.

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

I need to make "Italic" Italic font and bold "Bold".

Can anyone help me?

like image 925
Phoenix Avatar asked Jul 11 '15 07:07

Phoenix


1 Answers

I solved it.

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;
like image 109
Phoenix Avatar answered Nov 11 '22 16:11

Phoenix