设置同一Label内涵不同颜色字体
UILabel * label = [[UILabel alloc]init];
NSString * htmlString = @"<span style=\"font-family:Helvetica;font-size:15pt;color:#9DC216\">感谢使用 </span> <span style=\"font-family:Helvetica;font-size:15pt;color:#222332\">Uday 友电</span>";
NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType} documentAttributes:nil error:nil];
label.attributedText = attrStr;
label.textAlignment = NSTextAlignmentCenter;
[self.view addSubview:label];

浙公网安备 33010602011771号