Skip to content

Instantly share code, notes, and snippets.

@seanwolter
Created January 20, 2014 23:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanwolter/8531649 to your computer and use it in GitHub Desktop.
Save seanwolter/8531649 to your computer and use it in GitHub Desktop.
NSString *htmlString = @"<h1>Header</h1><h2>Subheader</h2><p>Some <em>text</em></p><img src='http://blogs.babble.com/famecrawler/files/2010/11/mickey_mouse-1097.jpg' width=70 height=100 />";
NSData *data = [htmlString dataUsingEncoding:NSUnicodeStringEncoding];
NSDictionary *attributes = @{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType };
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:data options:attributes documentAttributes:nil error:nil];
textView.attributedText = attributedString;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment