我的扩展名为get
NSAttributedString
并且在tableCell中有标签,其中我要添加属性HTML内容字符串,例如
extension NSAttributedString {
convenience init?(htmlString: String, font: UIFont, colorCode: String) {
let styledHTMLString = "<span style=\"font-family:\(font.fontName); color:\(colorCode) ;font-size:\(font.pointSize)px\">\(htmlString)</span>"
guard let data = styledHTMLString.data(using: String.Encoding.utf8) else { return nil }
do {
try self.init(data: data,
options: [.documentType: NSAttributedString.DocumentType.html,
.characterEncoding: NSNumber(value: String.Encoding.utf8.rawValue)],
documentAttributes: nil)
} catch {
return nil
}
}
}
但是在运行时,我遇到了红色标记所示的空间问题
我如何删除该空间?