2
votes

I have in my application a UIWebView that is it used often to display informatin to the user.

I have a requirement that is that the user should be able to change the font size of that web view to display the text bigger or smaller.

What I've done is to hook up two buttons in my ViewController that calls a JS script in my web view that changes the HTML body font size.

It is working nice, but if the user changes in the iPhone Settings the text size it doesn't affect my web view fonts.

Is it possible to use something like the methods preferredFontForTextStyle in a UIWebView natively?

1

1 Answers

0
votes
 NSString *jsForTextSize = [[NSString alloc] initWithFormat:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '%f%%'", changeFontSize*100/defaultFontSize];

 [self.webView stringByEvaluatingJavaScriptFromString:jsForTextSize];