Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Overlapping views in a view controller
override func loadView() {
let view = NSView(frame: .zero)
view.addSubview(vfxView)
view.addSubview(webView)
vfxView.translatesAutoresizingMaskIntoConstraints = false
webView.configuration.preferences.javaScriptEnabled = true
webView.setValue(false, forKey: "drawsBackground")
webView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
vfxView.topAnchor.constraint(equalTo: view.topAnchor),
vfxView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
vfxView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
vfxView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
webView.topAnchor.constraint(equalTo: view.topAnchor),
webView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
webView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
webView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
webView.widthAnchor.constraint(greaterThanOrEqualToConstant: 400)
])
self.view = view
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.