milanjansari milanjansari - 6 months ago 39
iOS Question

Display html text in uitextview

How can I display HTML text in textview?

For example,

string <h1>Krupal testing <span style="font-weight:
bold;">Customer WYWO</span></h1>


Suppose text is bold so it display in textview as bold string
but I want display normal text. Is this possible in the iPhone SDK?

Answer

Use a UIWebView on iOS 5-.

On iOS 6+ you can use UITextView.attributedString, see http://stackoverflow.com/a/20996085 for how.


There's also an undocumented -[UITextView setContentToHTMLString:] method. Do not use this if you want to submit to AppStore.

Comments