How to change the font size in UIWebview
11,550
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];
Author by
Admin
Updated on June 04, 2022Comments
-
Admin almost 2 years
I have a
UIWebView
thatloadHTMLString
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 ];
-
Admin about 11 yearsThank you^99 times, thats worked for me
-
coder over 7 yearsThis is not working anymore for iOS 10.1.1, is there any alternative?