UILabel加载HTML

    NSString *string1 = @"<font color = "red">什么情况</font><br/>";

    UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(100, 100, 200, 20)];

    NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc]initWithData:[string1 dataUsingEncoding:NSUnicodeStringEncoding] options:@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType} documentAttributes:nil error:nil];

    label1.attributedText = attribute;

    label1.font = [UIFont systemFontOfSize:20.f];

    [self.view addSubview:label1];

原文地址:https://www.cnblogs.com/wuhanpjf/p/5011482.html