how to increase font size in UIWebView

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

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

11条回答
  •  一生所求
    2020-11-30 18:42

    Change the font size of the fetched HTML data by changing the occurrence of font size in the fetched html string to your required font size (40 in this example) in a method.

    strHtml = [self htmlEntityDecode:strHtml];//parsing the html string
    
    
    -(NSString *)htmlEntityDecode:(NSString *)string
    {    
    string = [string stringByReplacingOccurrencesOfString:@"14px;"   withString:@"40"];
    string = [string stringByReplacingOccurrencesOfString:@"15px;"   withString:@"40"];
    string = [string stringByReplacingOccurrencesOfString:@"16px;"   withString:@"40"];
    string = [string stringByReplacingOccurrencesOfString:@"17px;"   withString:@"40"];
    string = [string stringByReplacingOccurrencesOfString:@"18px;"   withString:@"40"];
    string = [string stringByReplacingOccurrencesOfString:@"19px;"   withString:@"40"];
    string = [string stringByReplacingOccurrencesOfString:@"20px;"   withString:@"40"];
    
     return string;
    }
    

    So the html string: span style='font-size: 20px; Becomes: span style='font-size: 40

    Note: Change the other occurrences like gt;, apos; too to get the desired string to load in your Webview.

提交回复
热议问题