uiwebview 加载html时字体变小 加载前或加载后改变字体大小

 

为加载时添加代码  30设置的字体大小  strings HTML代码 注意:如果设置了style必须把font去掉,不然没效果 有table也没效果

 margin 距离边界距离 

  适合自适应高度

 NSString *string = [NSString stringWithFormat:@"<html> "

     "<head> "

     "<style type="text/css"> "

     "body {margin:10;font-size: %d;} "

     "</style> "

     "</head> "

     "<body>%@</body> "

     "</html>",30,strings];

 

 //加载后改变webview字体大小

 

    [self.web stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '300%'"];

   成比例缩放字体

原文地址:https://www.cnblogs.com/wujie123/p/6117685.html