如何更改颜色和字体大小 UIWebview [英] How to change the color and font size UIWebview

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

问题描述

在我的应用程序中,我正在加载从 json 文件解析的 HTML 字符串,该字符串已经包含字体颜色和字体大小,但我需要更改字体的颜色和大小.要替换它,我已经使用了以下代码但它不起作用

In my application I am loading HTML String which is parsed from the json file the string already contain font color and font size but I need to change the color and size of the font. To replace that I have already use the followings code but its not working

NSString *webString = [[NSString alloc] initWithFormat:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '%d%%'", 
                          textFontSize];
    [web stringByEvaluatingJavaScriptFromString:webString];

有没有其他方法可以改变它.如果是,请给我建议答案.

Is there is any other way to change it.If yes means please suggest me the answer.

推荐答案

试试这个,

[webView  loadHTMLString:[NSString stringWithFormat:@"<div id ='foo' align='justify' style='font-size:14px; font-family:helvetica; color:#ffffff';>%@<div>",yourString] baseURL:nil];

它可能会帮助你....

it may helps you....

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

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