注意:这个方法只支持IOS7以上
NSString * htmlString = @"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];
时间: 2024-10-25 05:43:07