Member-only story
Creating attributed text from an HTML string
Every now and then you might have found yourself in the need to showing attributed text in your iOS app (e.g. in a UILabel) and considered how easy it is in HTML compared to an NSAttributedString.
Suppose you wanted to have a label with some underlined text, in HTML you would simply do the following:
Next word is <u>underlined</u>.
To achieve the same within a UILabel you should do something like this:
Wouldn’t it be great if you could just do the following?
Less verbose and more effective, don’t you agree?
It is not hard to achieve, you just need to create an extension to the NSAttributedString class, as follows: