qq_15024937
今个儿赛太阳
采纳率0%
2017-01-05 02:32

iOS Swift 中用JS改变UIWebView中fontSize后 UIWebView的高度

##iOS Swift 中用JS改变UIWebView中fontSize后 UIWebView的scrollView.contenSize.height 或 webView.sizeThatFits(CGSizeZero).height都不会改变

this is my code :

func webViewDidFinishLoad(webView: UIWebView) {
//height_origin
        self.webView.stringByEvaluatingJavaScriptFromString("document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '140%'")
//height_change        
       //let height = self.webView.scrollView.contentSize.height //height不变
        let height = self.webView.sizeThatFits(CGSizeZero).height //height不变
        if self.height != height {
            self.height = height
            self.delegate?.webViewLoadSuccess(height)
        }
        self.webView.snp_updateConstraints { (make) in
            make.height.equalTo(self.height)
        }
}               
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

相关推荐