UILabel 加载html 字符串,以及设置带删除线的字符串

 //添加删除线
   NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"¥%@",self.data[indexPath.row][@"packTargetPrice"] ]attributes:@{NSStrikethroughStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleSingle] }];
   cell.targetPriceLabel.attributedText = attribtStr;

        
 //加载HTML字符串:
   NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[self.data[indexPath.row][@"packDesc"] dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
   cell.midDetailLabel.attributedText=attrStr;

你可能感兴趣的:(UILabel 加载html 字符串,以及设置带删除线的字符串)