Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
716 B
1
Indexable
Never
func htmlText() -> NSAttributedString {
        let fontName = ".SFUI-Medium"
        let htmlString = """
            <htlml><head><style>body {font-family:'\(fontName)', -apple-system, sans-serif; font-size: 10pt; line-height: 15pt; color: #333333;}
    </style></head><body>test String with <a href="https://google.com"> LINK</a>
</body></html>
"""
        let htmlData = htmlString.data(using: .utf8)!
        let html = try! NSAttributedString(data: htmlData, options: [NSAttributedString.DocumentReadingOptionKey.documentType: NSAttributedString.DocumentType.html, NSAttributedString.DocumentReadingOptionKey.characterEncoding: String.Encoding.utf8.rawValue], documentAttributes: nil)
        return html
    }