获取网页高度

// MARK: 代理方法 -- WKWebView

func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {

LTLog("页面加载完成")

webView.evaluateJavaScript("document.body.offsetHeight") { (result, error) in

if error == nil {

var newFrame = webView.frame

newFrame.size.height = result as! CGFloat

webView.frame = newFrame

self.headerView.frame = CGRect(x: 0, y: 0, width: ScreenWidth, height: newFrame.size.height)

self.wkView.frame = CGRect(x: 0, y: 0, width: ScreenWidth, height: newFrame.size.height)

LTLog("web高度: \(newFrame.size.height)---headerView高度: \(self.headerView.frame.size.height)")

self.bigTableView.reloadData()

}

}

}

你可能感兴趣的:(获取网页高度)