0

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

enter image description here

How i can remove this space?

Abhishek Thapliyal
  • 3,497
  • 6
  • 30
  • 69

0 Answers0