Created
April 12, 2019 15:27
-
-
Save lfcj/a08a84eb0fc20f92849dbb49e6dfa435 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import WebKit | |
class ViewController: UIViewController { | |
lazy var webView: WKWebView = { | |
let mySVGImage = "<svg height=\"190\"><polygon points=\"100,10 40,180 190,60 10,60 160,180\" style=\"fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;\"></svg>" | |
let preferences = WKPreferences() | |
preferences.javaScriptEnabled = false | |
let configuration = WKWebViewConfiguration() | |
configuration.preferences = preferences | |
let wv = WKWebView(frame: .zero, configuration: configuration) | |
wv.scrollView.isScrollEnabled = false | |
wv.loadHTMLString(mySVGImage, baseURL: nil) | |
return wv | |
}() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
view.addSubview(webView) | |
webView.backgroundColor = .red | |
NSLayoutConstraint.activate([ | |
webView.topAnchor.constraint(equalTo: view.topAnchor), | |
webView.bottomAnchor.constraint(equalTo: view.bottomAnchor), | |
webView.leadingAnchor.constraint(equalTo: view.leadingAnchor), | |
webView.trailingAnchor.constraint(equalTo: view.trailingAnchor)]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment