Home > Web Front-end > HTML Tutorial > UILabel可以显示html文本_html/css_WEB-ITnose

UILabel可以显示html文本_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:23:40
Original
983 people have browsed it

NSString * htmlString = @"

 Some html string \n This is some text! ”;  

NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];  

UILabel * myLabel = [[UILabel alloc] initWithFrame:self.view.bounds];  

myLabel.attributedText = attrStr;  

[self.view addSubview:myLabel];

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template