美文网首页
iOS WKWebview 图片适应屏幕

iOS WKWebview 图片适应屏幕

作者: 蚯小麦 | 来源:发表于2020-08-05 10:45 被阅读0次
    NSString *htmls = [NSString stringWithFormat:@"<html> \n"
                               "<head> \n"
                               "<style type=\"text/css\"> \n"
                               "body {font-size:15px;}\n"
                               "</style> \n"
                               "</head> \n"
                               "<body>"
                               "<script type='text/javascript'>"
                               "window.onload = function(){\n"
                               "var $img = document.getElementsByTagName('img');\n"
                               "for(var p in  $img){\n"
                                  " $img[p].style.width = '100%%';\n"
                                   "$img[p].style.height ='auto'\n"
                               "}\n"
                               "}"
                               "</script>%@"
                               "</body>"
                               "</html>,htmlString];
    
    [self.webView loadHTMLString:htmls baseURL:nil];
    

    相关文章

      网友评论

          本文标题:iOS WKWebview 图片适应屏幕

          本文链接:https://www.haomeiwen.com/subject/mahbrktx.html