1

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...:)

D.M
  • 510
  • 6
  • 14
  • yes..but the comments in the section of the accepted answer doesn't seem to suggest the answer as helpful..But will try the other swift versions provided there. Thanks for the link anyways... – D.M Aug 09 '17 at 06:36

1 Answers1

7

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)
D.M
  • 510
  • 6
  • 14