Came across a couple of snippets I put together to add a CSS file to a web view. It seems like this would be easy, but it really wasn’t, at least for me. As a side note, I am iPhone app developer and I am still learning everyday. So here’s the snippet:
Put it in the viewDidLoad,
NSString *bodyHTML = [NSString stringWithFormat:@"<html> \n" "<head> \n" "<link href=\"default.css\" rel=\"stylesheet\" type=\"text/css\" /> \n" "</head> \n" "<body\">%@</body> \n" "</html>", webLink];
NSString *path = [[NSBundle mainBundle] bundlePath]; NSURL *baseURL = [NSURL fileURLWithPath:path]; [webView loadHTMLString:bodyHTML baseURL:baseURL];