Reputation: 2601
I need to have text read from Firebase
on a Swift3
iOS
App with special format.
I want to be able to make something like this attached image.
How should I Write my text on Firebase
Database
, and how can I interpret it to give it colors, Bolds, Bullet Points
, Etc? Like if i was HTML content or rich text.
Thanks!
Upvotes: 1
Views: 827
Reputation: 847
You use HTML tags to format your text and write it in Firebase.
Your text will be something like this:
<h1 style="color:blue;">Your Title</h1>
<p>
My super description/text
</p>
Then write this example in your Firebase.
Now display you HTML content (Swit 2.0):
let myHtmlStringContent = "" // Your HTML content from Firebase
var attrStr = try! NSAttributedString(data: myHtmlStringContent.dataUsingEncoding(NSUnicodeStringEncoding, allowLossyConversion: true)!,
options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil)
label.attributedText = attrStr // Your IBOutlet
Upvotes: 2