iPhone Development - Setting UIWebView font

后端 未结 9 2093
别那么骄傲
别那么骄傲 2020-11-28 04:00

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 chan

9条回答
  •  生来不讨喜
    2020-11-28 04:39

    I made a method that wraps some text in a HTML body with the correct style for a given UIColor and UIFont. It is based on Mustafa answer.

    It is used like this:

    NSString * htmlString = [MyClass htmlFromBodyString:@"an example"
                                               textFont:[UIFont systemFontOfSize:10]
                                              textColor:[UIColor grayColor]];
    [webView loadHTMLString:htmlString baseURL:nil];
    

提交回复
热议问题