- , .
@IBOutlet weak var wkWebBackgroundView: UIView!
var wkWebView:WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
setUpView()
}
func setUpView(){
self.wkWebView = WKWebView(frame: CGRect.zero)
self.wkWebBackgroundView.addSubview(wkWebView)
let height = NSLayoutConstraint(item: wkWebView, attribute: .height, relatedBy: .equal, toItem: wkWebBackgroundView, attribute: .height, multiplier: 1, constant: 0)
let width = NSLayoutConstraint(item: wkWebView, attribute: .width, relatedBy: .equal, toItem: wkWebBackgroundView, attribute: .width, multiplier: 1, constant: 0)
let top = NSLayoutConstraint(item: wkWebView, attribute: .top, relatedBy: .equal, toItem: wkWebBackgroundView, attribute: .top, multiplier: 1, constant: 0)
let leading = NSLayoutConstraint(item: wkWebView, attribute: .leading, relatedBy: .equal, toItem: wkWebBackgroundView, attribute: .leading, multiplier: 1, constant: 0)
view.addConstraints([leading, top, height, width])
}