Вход на сайт

Просмотр новости

Найдите то, что Вас интересует

SwiftUI Toolbars

Дата публикации: 08-09-2026 20:12:55

Natalia Panferova: I thought it would be useful to have a single reference for the different ways we can style the toolbar in SwiftUI on macOS 26. Phil Zakharchenko: The toolbar id creates a stable customization domain, and each item id gives the framework something stable to persist when the user adds, removes, or reorders […]

Основное содержимое страницы с новостью.

Natalia Panferova:

I thought it would be useful to have a single reference for the different ways we can style the toolbar in SwiftUI on macOS 26.

Phil Zakharchenko:

The toolbar id creates a stable customization domain, and each item id gives the framework something stable to persist when the user adds, removes, or reorders controls. This identifiability of toolbar items is a requirement for customization. Under the hood, when SwiftUI inevitably bridges your toolbar contents to NSToolbar, these identifiers will be directly translated to the NSToolbarItem’s itemIdentifiers.

As we continue the migration to a customizable toolbar, we are likely to encounter a few surprises related to this model.

[…]

After a closer inspection, and perhaps a few minutes of digging through the documentation, we come to the bleak realization: there is no customizable ToolbarItemGroup API.

[…]

The regular toolbar model and the customizable toolbar model overlap, but they are not interchangeable. You cannot give a ToolbarItemGroup an id, and you cannot place one directly inside toolbar(id:content:).

Majid Jabrayilov:

Let’s take a look at another example. This one is a bit tricky, because on macOS, you will get Action 1 in the top trailing position and the whole group of actions centered in the navigation bar. On iOS, you will get Action 1 pinned to trailing and all other items collapsed.

[…]

The final addition to the Toolbar API is the toolbarMinimizeBehavior view modifier allowing us to minimize toolbars while scrolling up or down. You can minimize tab, bottom, window and navigation bars with it.

With new modifiers SwiftUI gives us a much better balance between system-driven adaptation and explicit control. We can now decide which actions are more important, which items should always stay visible, which groups should intentionally live in the overflow menu, and how toolbars should react to scrolling.

Natalia Panferova:

iOS 27 includes a few smaller additions that make toolbar content easier to configure.

We can remove the default padding around an item whose content should extend to its edges with contentMarginsRemoved(_:)[…]

[…]

The status bar is now represented by ToolbarPlacement.statusBar, so its visibility can be controlled through the same toolbar API as other bars[…]

[…]

ForEach now conforms to ToolbarContent, which means we can generate toolbar items directly from a collection[…]

Natascha Fadeeva:

Together, the toolbar APIs let us express the importance of each action while SwiftUI continues to handle the toolbar’s layout across different sizes.

Previously:

iOS iOS 27 Mac macOS 27 Golden Gate Programming Swift Programming Language SwiftUI

2 Comments

Схожие новости

#Наименование новостиТональностьИнформативностьДата публикации
1NSToolbar in Golden Gate013.1208-09-2026
2Backporting SwiftUI APIs013.7430-09-2026
3Developing for iPhone Duo09.7111-09-2026
4TipKit for the Real World013.8401-09-2026
5Xcode 27 RC Released020.1914-09-2026
6iOS 27018.2614-09-2026
7How to Always Show Menu Bar on iPad with iPadOS 2705.3123-09-2026
8Xcode 27.1 Beta 1 Released019.5922-09-2026
9Accessing the Keychain Without the Password013.0801-10-2026
10Xcode 27 Released020.1914-09-2026

Классификация: . Схожих патентов: 0. Схожих новостей: 10. Тональность: 0. Информативность: 9.7. Источник: mjtsai.com.