Issue #610
Set NSVisualEffectView
as contentView of NSWindow, and our main view as subview of it. Remember to set frame or autoresizing mask as non-direct content view does not get full size as the window
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 let mainView = MainView () .environment(\.managedObjectContext, coreDataManager.container.viewContext) window = NSWindow ( contentRect: .zero, styleMask: [.fullSizeContentView], backing: .buffered, defer : false ) window.titlebarAppearsTransparent = true window.center() window.level = .statusBar window.setFrameAutosaveName("MyApp" ) let visualEffect = NSVisualEffectView ()visualEffect.blendingMode = .behindWindow visualEffect.state = .active visualEffect.material = .sidebar let hosting = NSHostingView (rootView: mainView)window.contentView = visualEffect visualEffect.addSubview(hosting) hosting.autoresizingMask = [.width, .height]
Updated at 2021-01-05 21:13:39