How to configure a macOS toolbar to have items only in the sidebar area
Generated on 7/31/2024
1 search
To configure a macOS toolbar to have items only in the sidebar area, you can use the new itemidentifiers
property introduced in macOS Sequoia. This property allows you to set the toolbar's item identifiers programmatically, which automatically handles the minimal additions and removals for you.
Here are the steps to achieve this:
-
Set the
itemidentifiers
Property: Use theitemidentifiers
property to specify which items should be in the toolbar. This will ensure that only the specified items are displayed. -
Disable User Customization: If you want to ensure that the toolbar items remain fixed and are not customizable by the user, make sure that
allows user customization
is disabled. This will prevent any user changes from overriding your specified configuration. -
Use the
is hidden
Property: You can conditionally hide and show toolbar items using the newis hidden
property. Hidden items will still appear in customization options, allowing users to choose where they want them to appear when made visible.
For more detailed information, you can refer to the session What’s new in AppKit (15:16).
Relevant Sessions
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.
Elevate your tab and sidebar experience in iPadOS
iPadOS 18 introduces a new navigation system that gives people the flexibility to choose between using a tab bar or sidebar. The newly redesigned tab bar provides more space for content and other functionality. Learn how to use SwiftUI and UIKit to enable customization features – like adding, removing and reordering tabs – to enable a more personal touch in your app.
Migrate your TVML app to SwiftUI
SwiftUI helps you build great apps on all Apple platforms and is the preferred toolkit for bringing your content into the living room with tvOS 18. Learn how to use SwiftUI to create familiar layouts and controls from TVMLKit, and get tips and best practices.
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.