Sunday, December 10, 2023
HomeiOS Developmentswift - The best way to animate SF Image in a TabView...

swift – The best way to animate SF Image in a TabView in SwiftUI on iOS 17+


With iOS 17 Apple offers us the likelihood to animate SF Symbols utilizing the brand new symbolEffect() modifier. I am not in a position to animate symbols in a TabView. I present you some code:

struct MyApp: App {
    @State non-public var gearTabEffect: Bool = false

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

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

Am I doing one thing incorrect or it is a bug (or function 😄)?



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments