How to change the font size in UIWebview
font-size, ios, objective-c, uiwebview
Solution
Put this code in your `webViewDidFinishLoad` delegate method:
-(void)webViewDidFinishLoad:(UIWebView *)webView1{
int fontSize = 20;
NSString *jsString = [[NSString alloc] initWithFormat:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '%d%%'", fontSize];
[webView1 stringByEvaluatingJavaScriptFromString:jsString];
[jsString release];
}
Hope it helps ;)
Update: For developers who enabled ARC, you should ignore adding:
[jsString release];
Problem
I have a `UIWebView` that `loadHTMLString` from an array. I need this webView to change the font size dynamically here is how i fill my WebView: ``` [webView loadHTMLString:[NSString stringWithFormat:@"%@<p class=\"paragraph\" style=\"float: right\" >%@</p>",css,[[ contentArray objectAtIndex:0] valueForKey:@"content"]] baseURL:nil ]; ```