In the Html class, Android has:
public static Spanned fromHtml (String source)
which according to the documentation:
Returns displayable styled text from the provided HTML string.
.. and combining that with:
public void setText (CharSequence text, TextView.BufferType type)
which according to the TextView documentation:
Sets the text that this TextView is to display (see
setText(CharSequence)) and also sets whether it is stored in a
styleable/spannable buffer and whether it is editable.
.. makes it possible to display a string with HTML markup in a TextView ( example from this StackOverflow answer ):
String styledText = "This is <font color='red'>simple</font>.";
textView.setText(Html.fromHtml(styledText), TextView.BufferType.SPANNABLE);
My question is – what is the equivalent to this in iOS?
I have done some research, and it seems that people recommends using the UIWebView for this purpose – but is that really the only solution? And is it the recommended solution?
Thanks.
Apple itself recommends it, so it must be a quite good alternative solution…
If you really, badly don’t want to use UIWebView, you can use NSAttributedString objects and render one-line text using OHAttributedLabel.