1

coming to the point, I have one URL load in WKWebView, loading URL contains a single SVG image large size.

I am able to zoom in the image but could not able to zoom out.

let's say I have 1400 * 1200 size image that will not fit into screen. I can able to zoom in but when I try to zoom out it set to intal scale.

 let viewPortScript = """
                   var meta = document.createElement('meta');
                   meta.setAttribute('name', 'viewport');
                   meta.setAttribute('content', 'width=device-width');
                   meta.setAttribute('initial-scale', '1.0');
                   meta.setAttribute('maximum-scale', '1.0');
                   meta.setAttribute('minimum-scale', '0.0');
                   meta.setAttribute('user-scalable', 'yes');
                   meta.setAttribute('shrink-to-fit', 'yes');
                   document.getElementsByTagName('head')[0].appendChild(meta);
               """

        self.webview.scrollView.minimumZoomScale = 0.0
webview.evaluateJavaScript(viewPortScript, completionHandler: nil)
Kushal Maniyar
  • 846
  • 1
  • 8
  • 26

0 Answers0