我正在制作一个 epub 阅读器,我将 HTML 页面加载到其中webview
:
[_webview loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:_pagesPath]]];
现在我想更改 HTML 页面的背景颜色和文本颜色。我使用更改了网络视图的背景颜色,
self._webview.backgroundColor = [UIColor blackColor];
self._webview.opaque = NO;
这是可行的,但我还想更改我的网络视图的文本颜色。我该怎么做呢?
在这段代码中color:#fff
标签用于文本颜色 #fff 使用黑色
NSString *webStr =@"Your text use";
[self._webview loadHTMLString:[NSString stringWithFormat:@"<div id ='foo' align='left' style='line-height:18px; float:left;width:300px; font-size:13px;font-family:helvetica;background-color:transparent; color:#fff;>%@<div>",webStr] baseURL:nil];
如果你使用本地 HTML the use
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"html"];
NSString* text = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
NSLog(@"%@",htmlFile);
NSLog(@"Hello");
[self._webview loadHTMLString:[NSString stringWithFormat:@"<html><body bgcolor=\"#000000\" text=\"#FFFFFF\" face=\"Bookman Old Style, Book Antiqua, Garamond\" size=\"5\">%@</body></html>", text] baseURL: nil];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)