Post

Replies

Boosts

Views

Activity

Reply to Instantiating "HTML-styled" NSAttributedString in a View's body produces weird behaviour
for UITextView use: func updateUIView(_ uiTextView: UITextView, context: Context) { DispatchQueue.main.async { let data = Data(self.html.utf8) if let attributedString = try? NSAttributedString(data: data, options: [.documentType: NSAttributedString.DocumentType.html, .characterEncoding: NSUTF8StringEncoding], documentAttributes: nil) { uiTextView.attributedText = attributedString } } } and in SwiftUi body just sent html data = """ your html with doctype, header, body etc """ AttributedText(data)
Oct ’23