how to increase font size in UIWebView

前端 未结 11 1034
广开言路
广开言路 2020-11-30 18:12

how to increase or decrease the UIWebview font size, not using scalePageToFit:NO;

11条回答
  •  孤独总比滥情好
    2020-11-30 18:32

    I have 2 buttons - A- and 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];
    }
    

提交回复
热议问题