Change font and font color of text in UIWebView using swift

This question already has an answer here:

  • How to change UIWebView default font

    7 answers

I am displaying a text in webview like so..

webview.loadHTMLString(myText, baseURL: nil)

But I want to change the font type displayed in the webview by default to the font type of my choice. And I also want to change the font color. So what steps am I to take to achieve this. Thanks in advance…:)

Figured out how to change the font and font-color in swift…

In the viewDidLoad, I made a string type variable say, ‘myVariable’ and assign the font name and color to it like so…

myVariable = "<font face='Papyrus' size='3' color= 'red'>%@"

Then, in ViewDidLoad itself,

let var = String(format: myVariable, valueToPassInWebview)

Then, in ViewDidLoad itself, pass this value to the webview..

    webview.loadHTMLString(var, baseURL: nil)