ket*_*dhe 8 iphone background textcolor uiwebview ipad
我正在制作一个epub阅读器,我在其中加载HTML页面webview:
[_webview loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:_pagesPath]]];
Run Code Online (Sandbox Code Playgroud)
现在我想更改HTML页面的背景颜色和文本颜色.我改变了webview的背景颜色,
self._webview.backgroundColor = [UIColor blackColor];
self._webview.opaque = NO;
Run Code Online (Sandbox Code Playgroud)
这是有效的,但我也想改变我的webview的文本颜色.我该怎么做呢?
Dee*_*esh 12
在此代码 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];
Run Code Online (Sandbox Code Playgroud)
如果你使用本地html使用
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];
Run Code Online (Sandbox Code Playgroud)
[_webview loadHTMLString:[NSString stringWithFormat:@"<html><body style=\"background-color: white; font-size: 17; font-family: HelveticaNeue; color: #ffffff\">%@</body></html>", strDataFromHTML] baseURL: nil];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11196 次 |
| 最近记录: |