Skip to content

Instantly share code, notes, and snippets.

@gregoryvit
Last active September 28, 2023 18:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregoryvit/18060ab134c12f2c04e3d344965a9166 to your computer and use it in GitHub Desktop.
Save gregoryvit/18060ab134c12f2c04e3d344965a9166 to your computer and use it in GitHub Desktop.
WebView based Swift playground
//: Playground - noun: a place where people can play
import UIKit
import PlaygroundSupport
class ViewController:UIViewController{
lazy var webView: UIWebView = UIWebView(frame: self.view.bounds)
override func viewDidLoad() {
super.viewDidLoad()
self.configureWebView()
if let url = URL(string: <#URL String#>) {
let request = URLRequest(url: url)
self.webView.loadRequest(request)
}
}
private func configureWebView() {
self.view.addSubview(webView)
self.webView.delegate = self
}
}
extension ViewController: UIWebViewDelegate {
}
let viewController = ViewController()
PlaygroundPage.current.liveView = viewController.view
PlaygroundPage.current.needsIndefiniteExecution = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment