问题
I have a extension of NSAttributedString
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
}
}
}
and I have label in tableCell in which i'm adding attributed HTML content string like
let attributedText = NSAttributedString(htmlString: htmlContent,
font: UIFont.focoRegular(16.0),
colorCode: "464646")
self.descriptionLabel.attributedText = attributedText
But in runtime i'm facing space issue as shown in red mark
How i can remove this space?
来源:https://stackoverflow.com/questions/52314006/ios-uilabel-nsattributed-string-with-span-tag-getting-excessive-space-in-bottom