How to load html string to label and keep label styling?

تعرفه تبلیغات در سایت

آخرین مطالب

امکانات وب

Vote count: 0

So I have html string it contains all kinds of html tags, ascii symbols and I want to load this string to label but keep Label styling like font, textColor, textStyle main idea is to remove all html tags properly format Ascii symbols etc and return clean string and load it to Label.

Currently I use code below to format html, but like I said it totally ignores font, font size text color of label

func convertHtmlString(htmlString: String) -> NSAttributedString? {
    let data = htmlString.data(using: String.Encoding.unicode)! 
    let attrStr = try? NSAttributedString(
        data: data,
        options: [NSAttributedString.DocumentReadingOptionKey.documentType: NSAttributedString.DocumentType.html],
        documentAttributes: nil)
    NSAttributedString will do
    return attrStr
}
asked 11 secs ago
kosas

نویسنده : استخدام کار بازدید : 9 تاريخ : سه شنبه 22 خرداد 1397 ساعت: 3:40

فهرست وبلاگ