如何设置WebView的字体样式?

问题描述:

我使用这行代码设置字体和text.But本的尺寸是不工作如何设置WebView的字体样式?

NSString *[email protected]"<html><body style=\"font-family:Verdana; font-size:12px; color:#000000;\"></body></html>"; 
    [msgWebView setCustomTextEncodingName:abc]; 

请让我知道我可以设置文本的字体样式中的WebView。

+0

可能重复(http://*.com/questions/449773/iphone-development-setting-uiwebview-font) – doNotCheckMyBlog

+0

把风格标签中'头'标记,而不是'身体' – shannoga

+0

@ shannoga ..我现在使用这个,但它仍然不工作..还有一件事要说的是,我没有在webView中显示任何文本,用户将它输入文字,我想,通过用户输入的文本应该有这样的字体样式.. 的NSString * ABC = [的NSString stringWithFormat:@ “ \ n” “

\ N” “ \ n“ “body {font-family:\”%@ \“;字体大小:%@;} \ n”个 “ \ n” 个 “ \ n” 个 “ \ n” 个 “”,@ “宋体”,[NSNumber的numberWithInt:20]]; [ msgWebView setCustomTextEncodingName:abc]; – Nipun35

我觉得你正以错误的方式接近它。另一种方法是:

[[msgWebView preferences] setDefaultFontSize:12]; 
[[msgWebView preferences] setStandardFontFamily:@"Verdana"]; 
[iPhone发展 - 设置UIWebView中的字体]的
+0

为什么-1?只是好奇 – Vervious

+0

@vervious ...我不知道谁给你负面投票..但你的解决方案确实工作得很好..谢谢 – Nipun35

+0

此解决方案不会更改WebView字体 – loretoparisi