Last active
September 16, 2015 01:49
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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