如何增加或减少UIWebview字体大小,不使用scalePageToFit:NO;
最佳答案
我有 2 个按钮 - A- 和 A+
@interface
NSUInteger textFontSize;
- (IBAction)changeTextFontSize:(id)sender
{
switch ([sender tag]) {
case 1: // A-
textFontSize = (textFontSize > 50) ? textFontSize -5 : textFontSize;
break;
case 2: // A+
textFontSize = (textFontSize < 160) ? textFontSize +5 : textFontSize;
break;
}
NSString *jsString = [[NSString alloc] initWithFormat:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '%d%%'",
textFontSize];
[web stringByEvaluatingJavaScriptFromString:jsString];
[jsString release];
}
关于iphone - 如何在 UIWebView 中增加字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/589177/