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

 

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

 margin 距离边界距离 

  适合自适应高度

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

     "<head> \n"

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

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

     "</style> \n"

     "</head> \n"

     "<body>%@</body> \n"

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

 

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

 

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

   成比例缩放字体

posted @ 2016-11-30 14:30  原码  阅读(380)  评论(0编辑  收藏  举报