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).