Skip to content

Instantly share code, notes, and snippets.

@dolphinSuPixnet
Last active September 16, 2015 01:49
Show Gist options
  • Save dolphinSuPixnet/52ce8f8bdcb2da5dc27f to your computer and use it in GitHub Desktop.
Save dolphinSuPixnet/52ce8f8bdcb2da5dc27f to your computer and use it in GitHub Desktop.
We can use -initWithData:options:documentAttributes:error: create an HTML based string. 利用 -initWithData:options:documentAttributes:error: 建立 HTML 語法為基礎的 attributed string.
NSString *origin = @"<b><i>hello world</i></b>";
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:[origin dataUsingEncoding:NSUnicodeStringEncoding allowLossyConversion:YES]
options:@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType}
documentAttributes:nil
error:nil];
_label.attributedText = attributedString;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment