func layoutWithActivityModel(model:ActivityModel){
do{
let attrStr = try NSAttributedString(data: model.title!.data(using: String.Encoding.unicode, allowLossyConversion: true)!, options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil)
let txtAttrStr = try NSAttributedString(data: model.content!.data(using: String.Encoding.unicode, allowLossyConversion: true)!, options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil)
TxTLabel.attributedText = txtAttrStr
titleLabel.attributedText = attrStr
}catch let error as NSError {
print(error.localizedDescription)
}
}
上述方法是写在UITableViewCell中给cell上的UILabel赋值;
{ content = "<font color=\"#333333\" style=\"font-size:11pt;font-family:PingFangSC-Light\">11\U6708HR\U3001Diro\U6b63\U54c1\U7f8e\U5986\U6b63\U54c1<font style=\"font-weight:700;font-size:14pt;color:#ea094b;font-family:PingFangSC-Light\">0</font>\U5143\U53ef\U8d2d</font>";
title = "<font color=\"#333333\" style=\"font-size:12pt;font-weight:700;font-family:PingFangSC-Light\">\U8d85\U503c\U6708\U8d2d</font>";
}
{ content = "<font color=\"#333333\" style=\"font-size:11pt;font-family:PingFangSC-Light\">\U5f85\U8fd4\U91d1\U989d<font style=\"font-weight:700;font-size:14pt;color:#ea094b;font-family:PingFangSC-Light\">4</font>\U5468\U540e\U53ef\U63d0\U73b0,\U5347\U7ea7\U63d0\U901f<font style=\"font-weight:700;font-size:14pt;color:#ea094b;font-family:PingFangSC-Light\">7</font>\U5929!</font>";
title = "<font color=\"#333333\" style=\"font-size:12pt;font-weight:700;font-family:PingFangSC-Light\">\U6781\U901f\U63d0\U73b0</font>";
}
{content = "<font color=\"#666666\" style=\"font-size:11pt;font-family:PingFangSC-Light\">\U9a6c\U4e0a\U5230\U6765,\U656c\U8bf7\U671f\U5f85</font>";
title = "<font color=\"#333333\" style=\"font-size:12pt;font-weight:700;font-family:PingFangSC-Light\">\U7cbe\U54c1\U5c1d\U9c9c</font>";
}
以上是下发的html标签