Skip to content

Instantly share code, notes, and snippets.

@romaonthego
Created September 23, 2013 16:08
Show Gist options
  • Save romaonthego/6672863 to your computer and use it in GitHub Desktop.
Save romaonthego/6672863 to your computer and use it in GitHub Desktop.

Revisions

  1. romaonthego renamed this gist Sep 23, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. romaonthego created this gist Sep 23, 2013.
    13 changes: 13 additions & 0 deletions gistfile1.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    - (void)viewDidLoad
    {
    [super viewDidLoad];
    UITextView *textView = [[UITextView alloc] init];
    textView.translatesAutoresizingMaskIntoConstraints = NO;
    [self.view addSubview:textView];
    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[textView]-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(textView)]];
    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[textView]-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(textView)]];

    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 />";
    NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
    textView.attributedText = attributedString;
    }