I need to bold a text. Kind of paragraph and heading.
Example: Xamarin.iOS UITextView some text bold and some text with header
In the above example, I need to make bold and Header bold in Textview.
Kindly help.
I need to bold a text. Kind of paragraph and heading.
Example: Xamarin.iOS UITextView some text bold and some text with header
In the above example, I need to make bold and Header bold in Textview.
Kindly help.
You could implement it in code , i see you've got the answer here.
Another way : you could set attribute string directly in storyboard ,it is more simple and Intuitive.
Set Text style as Attributed
first , select the text and click font in properties menu , you could set bold and font size for all the headers ,refer to here .
However , I test it in Visual Studio for mac
and Visual Studio for windows
.
This feature works fine with the first one, but not supported in visual studio for windows
.
So you can only do it in vs for mac
.
I have used HTML string to set bold because I have localization in my application.
public NSAttributedString ConvertBoldTextUsingHtml(string htmlString)
{
var err = new NSError();
var atts = new NSAttributedStringDocumentAttributes
{
DocumentType = NSDocumentType.HTML,
StringEncoding = NSStringEncoding.UTF8
};
return new NSAttributedString(NSData.FromString(htmlString), atts, ref err);
}
textView.AttributedText= ConvertBoldTextUsingHtml(htmlString)