What's new with NSWindow?

Asked on 08/01/2024

1 search

At WWDC 2024, Apple introduced several new features and improvements for NSWindow and window management in macOS, particularly through SwiftUI. Here are some of the key updates:

  1. Window Styles and Behavior Customization:

    • Plain Window Style: You can now use the plain window style to remove the default window chrome and create borderless windows. This is useful for creating floating windows or custom window designs.
    • Utility Windows: New scene types like utility windows have been introduced to help tailor the style and behavior of windows on macOS.
  2. Window Placement and Sizing:

    • Default Window Placement API: This API helps in placing windows at specific locations on the screen, taking into account the size of the display and the content.
    • Cascading Reference Frame: This property allows new windows to be positioned relative to existing windows, ensuring a more organized window layout.
    • Zoom to Fit: A helper function to make windows grow to fit the display, enhancing the user experience by making the window feel more aware of its content and the display.
  3. Toolbar and Title Customization:

    • Toolbar Removing Modifier: This modifier allows you to remove the toolbar and title from a window, which can be useful for creating a more immersive experience.
    • Toolbar Background Visibility Modifier: This modifier helps in customizing the toolbar background, making it possible to highlight specific content within the window.
  4. State Restoration and Minimize Behavior:

    • State Restoration Behavior: You can customize the state restoration behavior of windows, such as disabling state restoration for certain windows like the "About" window.
    • Window Minimize Behavior Modifier: This modifier allows you to disable the minimize control for windows that should not be minimized.
  5. New APIs and Enhancements:

    • Persistent System Overlays Modifier: This modifier can be used to hide the window bar and close button, allowing for a more focused user experience.
    • Push Window Action: This new action can be used to open a window and hide the originating window, helping to keep the most important content focused.

For more detailed information, you can watch the session Tailor macOS windows with SwiftUI.

Relevant Sessions

  1. Tailor macOS windows with SwiftUI
  2. Work with windows in SwiftUI
  3. What’s new in AppKit
  4. What’s new in SwiftUI

These sessions provide a comprehensive overview of the new features and improvements for window management in macOS.