You can get an instance of your application window as follow:
guard let window = NSApplication.shared().windows.first else { return }
window.isOpaque = false
window.backgroundColor = .clear
Get your window from NSApp (global constant for the shared app instance):
guard let window = NSApp.windows.first else { return }
Or override viewWillAppear
or viewDidAppear
and access your view's window property.
override func viewWillAppear() {
super.viewWillAppear()
view.window?.isOpaque = false
view.window?.backgroundColor = .clear
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…