Au Ris Au Ris - 10 months ago 125
iOS Question

How to change UIWebView default font

What font does UIWebView use by default? I would like to be able to change that. But I don't want to do it in the html string, instead I want to have something like:

[webView setFont:[UIFont fontWithName:@"GothamRounded-Bold" size:14]

is there such property or some other way?


Just prefix a <font face> tag to your string before loading into the webView.

NSString *body = [plist objectForKey:@"foo"];
NSString *htmlString = 
    [NSString stringWithFormat:@"<font face='GothamRounded-Bold' size='3'>%@", body];
[webView loadHTMLString:htmlString baseURL:nil];