swift – How to animate SF Symbol in a TabView in SwiftUI on iOS 17+


With iOS 17 Apple gives us the possibility to animate SF Symbols using the new symbolEffect() modifier. I’m not able to animate symbols in a TabView. I show you some code:

struct MyApp: App {
    @State private var gearTabEffect: Bool = false

    var body: some View {
        WindowGroup {
                TabView {
                    DashboardView()
                        .tabItem { Label("Dashboard", systemSymbol: ._01Square) }

                    SettingsView()
                        .tabItem { Label("Settings", systemImage: "gear").symbolEffect(.pulse, value: gearTabEffect) }
                        .onAppear {
                            print("settings view appeared")
                            gearTabEffect.toggle()
                        }
            }
        }
    }
}

Am I doing something wrong or it’s a bug (or feature 😄)?

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img