What's new with NSWindow?

Generated on 8/1/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.

What’s new in AppKit

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.

Work with windows in SwiftUI

Work with windows in SwiftUI

Learn how to create great single and multi-window apps in visionOS, macOS, and iPadOS. Discover tools that let you programmatically open and close windows, adjust position and size, and even replace one window with another. We’ll also explore design principles for windows that help people use your app within their workflows.

What’s new in SwiftUI

What’s new in SwiftUI

Learn how you can use SwiftUI to build great apps for any Apple platform. Explore a fresh new look and feel for tabs and documents on iPadOS. Improve your window management with new windowing APIs, and gain more control over immersive spaces and volumes in your visionOS apps. We’ll also take you through other exciting refinements that help you make expressive charts, customize and layout text, and so much more.

Platforms State of the Union

Platforms State of the Union

Discover the newest advancements on Apple platforms.

Tailor macOS windows with SwiftUI

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.