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];
让UIKit(UIView,UILabel等)直接显示网页内容
最新推荐文章于 2021-06-25 19:11:00 发布