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

查看:12
本文介绍了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)?

我现在正在做这样的事情:

I'm doing something like this at the moment:

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天全站免登陆