我有一个web视图。因为我想调用一个css文件。下面的代码我在web视图中添加了一个css文件,但它没有显示任何内容。 我的css文件名是:style.css。第一行编码在style.css中。在webview中添加一个css文件
p{color:#eadfa8},p a{color:#fff; text-decoration:none;}
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"style" ofType:@"css"];
NSString *htmlString = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
NSURL *baseURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
[webView loadHTMLString:htmlString baseURL:baseURL];
该文件中:
雅感谢您bro.i使用的内容在网络视图中,但风格是不会改变兄弟。 – gowtham