Skip to content

An example implementation of NSWindow with advanced toolbar capabilities in a SwiftUI app.

License

Notifications You must be signed in to change notification settings

stephancasas/swiftui-advanced-toolbar-app

Repository files navigation

swiftui-advanced-toolbar-app

An example implementation of NSWindow with advanced toolbar capabilities in a SwiftUI-based macOS application.

Why?

Because window management for macOS apps using SwiftUI's lifecycle is goofy, and I'm not using this ridiculous workaround in my app:

@main
struct MyApplication: App {
    var body : some Scene {
        Window("Some Window", id: "some-window") {
            ContentView().background(WindowAccessor())
        }
    }
}

struct WindowAccessor: NSViewRepresentable {
    func makeNSView(context: Context) -> NSView {
        let view = NSView()
        DispatchQueue.main.async {
            view.window?.titlebarAppearsTransparent = true
        }
        return view;
    }

    func updateNSView(_ nsView: NSView, context: Context) { }
}

Until Apple starts paying some level of serious attention to SwiftUI's implementation on macOS, I'll continue to use NSWindow.

License

MIT

About

An example implementation of NSWindow with advanced toolbar capabilities in a SwiftUI app.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages