Search code examples
iosuiwebview

UIWebView : Get Webview Content size?


I have loaded HTML in webview.  I want to dynamically update font size(increase or decrease) of text loaded in web view Same as in Apple News Article app. But According to my design I need to stop web view scrolling and need to update it height according to text. So I need to get content size of article, but I am not getting it proper. Can anyone help?


Solution

  • When font change at that time change Webview height to 1 than get proper offsetHeight for Webview

    webView1.frame.size.height = 1
    let size : String = self.webView1.stringByEvaluatingJavaScript(from: "document.documentElement.offsetHeight")!