How to make a UIWebView show its text with a custom font?
It looks like if the font in UIWebView is by default some kind of "Times New Roman". I guess I would have to figure out what font apple uses for [UIFont systemFontOfSize:15] ... o开发者_运维技巧r is there some intelligent way to do it?
How are you inserting text in the UIWebView? Assuming you are setting the HTML you can change the font either by full CSS, inline CSS or deprecated font tags.
<html>
<head>
<style>
BODY { font-family: 'Times New Roman'; font-size: 15px; }
</style>
</head>
<body>
Here is some text
</body>
</html>
Of course tweak style and size appropriately.
[myWebView loadHTMLString:[NSString stringWithFormat:@"<html><head><style>BODY { font-family: 'Arial-Bold'; font-size: 16px; }</style></head><body>%@</body></html>",htmlBodyString] baseURL:nil];
精彩评论