Search code examples
htmliosuitextviewnsattributedstringpre

What's the NSAttributedString conversion equivalent of the <pre> tag?


I am parsing HTML tags right now for rendering in a UITextView using NSAttributedStrings.

I'm a bit unsure as to how text encased in <pre> tags should render in a UITextView as an attributed string.

Should it just be formatted in the Courier font, or is there more to the <pre> tag?

Example:

This is text
that     is inside of
a pre tag

Solution

  • Yes, the font should be Courier (or any other monospaced font that looks decent). You may also have to tweak certain whitespace characters, like tabs (i.e. convert them to spaces).

    (Why not just use a UIWebView?)