HomeiOS DevelopmentToolbar animation solely performs when switching state quickly

Toolbar animation solely performs when switching state quickly


I’m testing the iOS 26 Liquid Glass toolbar habits in SwiftUI. Toolbars have a morphing/materialize animation when their content material adjustments throughout navigation.

In my case, I’m switching toolbar gadgets utilizing a segmented Picker (not navigation). The toolbar contents do change, however the Liquid Glass animation solely performs if I swap tabs in a short time. If I swap usually, the toolbar updates immediately with no animation.

struct ContentView: View {

    @State non-public var tab: Tabs = .tab1

    var physique: some View {
        NavigationStack {
            ZStack {
                swap tab {
                case .tab1:
                    Textual content("Tab 1")
                        .toolbar {
                            ToolbarItem(placement: .topBarLeading) {
                                Button("Tab 1 Button", systemImage: "particular person") { }
                            }
                        }

                case .tab2:
                    Textual content("Tab 2")
                        .toolbar {
                            ToolbarItem(placement: .topBarLeading) {
                                Button("Tab 2 Button", systemImage: "plus") { }
                            }
                            ToolbarItem(placement: .topBarLeading) {
                                Button("Tab 2 Button", systemImage: "trash") { }
                            }
                        }
                }
            }
            .animation(.default, worth: tab)
            .navigationTitle("Testing Toolbar")
            .toolbarTitleDisplayMode(.inline)
            .safeAreaBar(edge: .high) {
                Picker("Picker", choice: $tab) {
                    Textual content("Tab 1").tag(Tabs.tab1)
                    Textual content("Tab 2").tag(Tabs.tab2)
                }
                .pickerStyle(.segmented)
            }
        }
    }

    enum Tabs {
        case tab1
        case tab2
    }
}

Habits:

  • Switching tabs usually → toolbar adjustments with out Liquid Glass animation

    Toolbar animation solely performs when switching state quickly

  • Switching tabs quickly → Liquid Glass morph animation does play

    test2

Is there a approach to drive the Liquid Glass animation when toolbar gadgets change as a consequence of state updates (like a segmented picker)?

I would like the separate toolbars to remain connected to their respective view inside the ZStack.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments