更改文本颜色的UIWebView的 [英] Change textcolor of UIWebView

查看:220
本文介绍了更改文本颜色的UIWebView的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我作出EPUB阅读器,在其中我加载在我的的WebView的HTML页面

I am making an epub reader, into which I am loading HTML pages in my webview:

[_webview loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:_pagesPath]]];

现在我想改变背景颜色和与我的HTML页面的文本颜色。我使用改变了我的WebView的背景颜色,

Now I want to change background color and and text color of my the HTML pages. I changed background color of my webview using,

self._webview.backgroundColor = [UIColor blackColor];
self._webview.opaque = NO;

这的工作,但我也想改变我的WebView的文本颜色。我该怎么做呢?

That's working, but I also want to change the text color of my webview. How do I do this?

推荐答案

在此此code 颜色:#FFF 为#FFF使用黑色文本颜色标记使用颜色

In this this code color:#fff tag use for text color #fff use black color

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 使用

 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];

这篇关于更改文本颜色的UIWebView的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆