Hi, I've got this html text:
"<style>* {font-size: 12pt !important;color: #000000 !important;font-family: Montserrat-Regular !important;}</style>Perform the following steps:<br><u>Option 1:</u><br><p>1) Upon receiving a push notification alert, tap on the push notification to launch BIMB Authenticator</p><p>2) Verify the transaction details and choose \"Approve\"</p><p>3) Complete</p><br><u>Option 2:</u><br><ol><p>1) If you didn’t receive push notification, you may launch BIMB Authenticator</p><p>2) Verify the transaction details and choose \"Approve\"</p><p>3) Complete</p>"
And I'm trying to show this HTML text properly in a UILabel. This is my codes:
String extension to map to NSAttributedString:
extension String {
func attributedStringFromHTML() -> NSAttributedString? {
guard let data = "\(self)"
.data(using: .utf8, allowLossyConversion: false) else {
Log.error(category: .transaction, message: "Unable to decode data from html string: %@", self)
return nil
}
let options: [NSAttributedString.DocumentReadingOptionKey: Any] = [
.documentType: NSAttributedString.DocumentType.html,
.characterEncoding: String.Encoding.utf8.rawValue
]
if let attributedString = try? NSAttributedString(data: data, options: options, documentAttributes: nil) {
return attributedString
} else {
Log.error(category: .transaction,
message: "Unable to create attributed string from html string: %@",
self)
return nil
}
}
}
And this is the result:
Can you tell me how to fix this? Thanks.
CSS
RSS for tagCascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language like HTML.
Posts under CSS tag
22 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I have a Website live on http://chatwithsanta.azurewebsites.net/
It uses Flexbox to show chat messages and a chat message input.
Specifically, the Body is a flexbox container with a message screen containing messages, and a message input form at the bottom.
This layout works in Chrome on desktop, even when Chrome is set to simulate an iPhone 12 Pro layout.
But the form does not appear on my own iPhone.
What should I do?