I am making an epub reader, into which I am loading HTML pages in my webview
:
[_webview loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:_pagesPath]]];
Now I want to change background color and and text color of my the HTML pages. I changed background color of my webview using,
self._webview.backgroundColor = [UIColor blackColor];
self._webview.opaque = NO;
That's working, but I also want to change the text color of my webview. How do I do this?
try to add the code in your HTML file what ever you are getting from server... then only you can change the text color.... or add some HTML code before your HTML file for changing the color of text
In this this code
color:#fff
tag use for text color #fff use black colorif you use local html the use
I made a method that wraps some text in a HTML body with the correct style for a given
UIColor
andUIFont
.Simply pop the generated HTML into the webview:
try this...
Hope this helps.
Here is a small Swift Extension to handle this: