Monday 28 April 2014


how to increase font size in UIWebView:

I have 2 buttons - A- and A+ : 
 
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%%'",ctextFontSize];
    [web stringByEvaluatingJavaScriptFromString:jsString];
}

No comments:

Post a Comment