iPhone开发 - 设置UIWebView字体 [英] iPhone Development - Setting UIWebView font

查看:92
本文介绍了iPhone开发 - 设置UIWebView字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须显示我从服务器提取的富文本,因此我使用的是UIWebView。现在问题是我无法控制UIWebView中使用的字体。如何更改字体以使用系统字体(使其与应用程序的其余部分保持一致)?

I have to show rich text that i pull from server, so i'm using UIWebView. Now the problem is that i have no control over the font which is used in UIWebView. How can i change the font to use system font (making it consistent with rest of the application)?

我正在做这样的事情:

myRichTextView = [[UIWebView alloc] initWithFrame:CGRectMake(x, y, width, height)];
myRichTextView.backgroundColor = [UIColor clearColor];
[myRichTextView setScalesPageToFit:NO];
[myRichTextView loadHTMLString:myString baseURL:[NSURL URLWithString:myBaseURL]];

再次,需要控制显示字体。如果我无法控制字体,请让我知道UIWebView的其他替代方案。

Again, need to control the display font. If i can't control the font, please let me know other alternatives to UIWebView.

谢谢

推荐答案

在HTML文档中引用css样式表或将样式信息放在HTML文档本身的顶部

Reference a css style sheet in your HTML document or put the style information into the top of the HTML document itself

这篇关于iPhone开发 - 设置UIWebView字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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