coskukoz coskukoz - 1 year ago 78
Swift Question

How to color html text?

I'm making pdf by iOS app and I just want to change title text color in Swift.

This is the black title:

let pageTitle = "<b>THIS IS TITLE</b>"

I tried this and got error:

let pageTitle = "<p color="red"><b>THIS IS TITLE</b></p>"

Also I tried this one and also got error:

let pageTitle = "<p style="color:red;"><b>THIS IS TITLE</b></p>"

I guess problem is just because of the symbol ". I replaced it by symbol ' but still same.

Answer Source

I have solved by adding CSS code with single quote! This gives red:

let pageTitle = "<p style='color:red;'><b>THIS IS TITLE</b></p>"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download