Last active
June 24, 2017 17:27
-
-
Save tunitowen/9599186 to your computer and use it in GitHub Desktop.
HTML to NSAttributedString
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 *html = @"<div style='font: 18pt Helvetica-Light; color: #3498DB;'>Blue Text<span style='color: #AAAAAA;'>GreyText</span></div>"]; | |
NSData *htmlData = [html dataUsingEncoding:NSUTF8StringEncoding]; | |
NSMutableAttributedString *htmlAttributedString = [[NSMutableAttributedString alloc] initWithData:htmlData options:@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType} documentAttributes:nil error:nil]; | |
[label setAttributedText:htmlAttributedString]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment