How do I force the titlebar of an NSWindow to be centered again?
Asked on 06/12/2025
1 search
To force the titlebar of an NSWindow
to be centered again, you can use the default window placement modifier in SwiftUI. This modifier allows you to set the initial position and size of a window programmatically. By default, macOS opens new windows at the center of the screen, and this behavior can be customized using the default window placement API.
For more detailed guidance on window placement in SwiftUI, you can refer to the session Work with windows in SwiftUI (06:15).

Build an AppKit app with the new design
Update your AppKit app to take full advantage of the new design system. We’ll dive into key changes to tab views, split views, bars, presentations, search, and controls, and show you how to use Liquid Glass in your custom UI. To get the most out of this video, we recommend first watching “Get to know the new design system” for general design guidance.

What’s new in AppKit
Discover the latest advances in Mac app development. Get an overview of the new features in macOS Sequoia, and how to adopt them in your app. Explore new ways to integrate your existing code with SwiftUI. Learn about the improvements made to numerous AppKit controls, like toolbars, menus, text input, and more.

Tailor macOS windows with SwiftUI
Make your windows feel tailor-made for macOS. Fine-tune your app’s windows for focused purposes, ease of use, and to express functionality. Use SwiftUI to style window toolbars and backgrounds. Arrange your windows with precision, and make smart decisions about restoration and minimization.