I use UIWebViewto download PDF and images with zoom function. To do this, I checked the webView.scalesPageToFitProperty for true, and it works fine.
But my problem is
When I upload large images (2496 * 3507), it shows the default Zoomed that I do not want the size to be
To solve this problem
I implemented a web view delegate with the following code
func webViewDidFinishLoad(_ webView: UIWebView) {
webView.contentMode = .scaleAspectFit
let zoom = webView.bounds.size.width / webView.scrollView.contentSize.width
webView .stringByEvaluatingJavaScript(from: "document.body.style.zoom = \(zoom);")
}
Now the default zoom problem is resolved, but web browsing allows you to scroll vertically and horizontally.
source
share