NSString *html = @"<bold>Wow!</bold> Now <em>iOS</em> can create <h3>NSAttributedString</h3> from HTMLs!";
NSDictionary *options = @{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType};
NSAttributedString *attrString = [[NSAttributedString alloc] initWithData:[html dataUsingEncoding:NSUTF8StringEncoding]
options:options documentAttributes:nil error:nil];
CATextLayer *textLayer = [CATextLayer layer];
textLayer.string = attrString;
textLayer.frame = CGRectMake(10, 60, 300, 400);
[self.view.layer addSublayer:textLayer];
转载于:https://www.cnblogs.com/skyry/p/5114565.html