Search code examples
iphoneobjective-cuitextviewunderlinebold

Underline / Bold in UITextView


Is it possible to underline or embolden certain bits of text in a UITextView?

For example my Text View has headings in it, and would like those underlined...

Random Mode
In random mode, you can generate numbers...

Sweepstake Mode
In sweepstake mode...

If not, what is the best way to achieve this?

Thanks


Solution

  • Use should use NSAttributedString, and use controllers for drawing NSAttributesString.

    Controller for NSAttributedString

    Note: you can't use UITextView to display a NSAttributedString

    Update

    From iOS6, UILabel now support NSAttributedString, you should use UILabel directly instead of OHAttributedLabel as it is now natively supported by the OS.