Swift Playground All In One_WKWebView Swift Playground All In One Xcode 11 WkWebView Swift 5.3



Swift Playground All In One

Swift 5.3

  1. Playgrounds in Xcode

Xcode 11.5

​https://developer.apple.com/videos/play/wwdc2018/402/​

  1. Learn to Code with Swift Playgrounds

​https://developer.apple.com/swift-playgrounds/​

Swift Playgrounds for iPad

​http://appstore.com/swiftplaygrounds​

Swift Playgrounds for Mac

​https://apps.apple.com/app/id1496833156​



demo

WkWebView

Swift Playground All In One_WKWebView

//: A UIKit based Playground for presenting user interface

import PlaygroundSupport

import UIKit
import WebKit
class ViewController: UIViewController, WKUIDelegate {
var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
let myURL = URL(string:"https://www.apple.com")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)
}
override func loadView() {
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
view = webView
}
}
// Present the view controller in the Live View window
PlaygroundPage.current.liveView = ViewController()


Swift Playground All In One_playground_03

//: A UIKit based Playground for presenting user interface

import UIKit
import PlaygroundSupport

class MyViewController : UIViewController {
override func loadView() {
let view = UIView()
view.backgroundColor = .white

let label = UILabel()
label.frame = CGRect(x: 150, y: 200, width: 200, height: 20)
label.text = "Hello World!"
label.textColor = .black

view.addSubview(label)
self.view = view
}
}
// Present the view controller in the Live View window
PlaygroundPage.current.liveView = MyViewController()