iOS UILabel显示HTML文本

只能在iOS7以后运行


NSString * htmlString = @" Some html string \nThis 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];

你可能感兴趣的:(iOS UILabel显示HTML文本)