Home >Web Front-end >HTML Tutorial >UILabel displays HTML text using native methods_html/css_WEB-ITnose

UILabel displays HTML text using native methods_html/css_WEB-ITnose

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-24 11:45:081110browse

NSString * htmlString = @"<html><body>今天中午<font size=\"13\" color=\"red\">去哪吃什么</font><font size=\"5\" color=\"blue\">???</font> </body></html>";    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];


Statement:
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