Hi,
My Code Snippet
myTextView.heightAnchor.constraint(greaterThanOrEqualToConstant: 20).isActive = true
let myHTMLString =" some html text"
myTextView.attributedText = myHTMLString.htmlToAttributedString
extension String {
var htmlToAttributedString: NSAttributedString? {
guard let data = data(using: .utf8) else { return NSAttributedString() }
do {
return try NSAttributedString(data: data, options: [.documentType: NSAttributedString.DocumentType.html, .characterEncoding:String.Encoding.utf8.rawValue], documentAttributes: nil)
} catch {
return NSAttributedString()
}
}
var htmlToString: String {
return htmlToAttributedString?.string ?? ""
}
}
HTMLString converted to attributed string.
But,
extra lines of white spaces exists in myTextView at the bottom.
What is the reason?
How to recitify it?
Thanks In Advance