Skip to content

Instantly share code, notes, and snippets.

Created January 19, 2017 09:09
What would you like to do?
WKWebView JavaScript Injection to block zoom.
// Remember to import WebKit at the top of the file
let source = "var meta = document.createElement('meta');" +
" = 'viewport';" +
"meta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no';" +
"var head = document.getElementsByTagName('head')[0];" +
let userContentController = WKUserContentController()
let configuration = WKWebViewConfiguration()
configuration.userContentController = userContentController
let webview = WKWebView(frame: .zero, configuration: configuration)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment