I'm looking for a way to load my UIWebView with a local CSS file that should affect on the UIWebView's loadRequest.
For the clearness: I have an UIWebView that I loadRequest it with a website url. I also have a local CSS file that should affect this loadRequest url.
I want to load this CSS file onto the UIWebView.
Thanks,
This stackoverflow question appears to have one or two answers that may help you.
You need to load the local CSS (using a method not unlike @Shrey uses, but looking for your CSS file), and somehow inject it into the page, and the only way appears to be to use:
[webview stringByEvaluatingJavaScriptFromString:someJavascriptToInjectCSS];
and some clever Javascript to modify the page to add the CSS in.
Hope this helps point you in the right direction. I have used this method to inject stuff into pages, so it does work, but I don't know Javascript well enough to write the code to inject your CSS into the page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With