SwiftUI: Rotate symbolEffect not working

Hello, I have the following code:

struct SettingsButton: View {
    
    var action: () -> Void
    
    @State private var rotate: Bool = false
    
    var body: some View {
        Button(action: {
            rotate.toggle()
            action()
        }, label: {
            Image(systemName: "gearshape")
        })
        .symbolEffect(.rotate, value: rotate)
    }
}

For some reason, my button is not rotating. Other effects such as pulse and bounce work as expected. I applied the .clockwise direction thinking it needed a direction set, but that didn't work either. I also tried using the symbolEffect with isActive, and that didn't work. Lastly, I thought there may be an issue with Xcode so I closed that and reopened, but still not working.

Any ideas?

Answered by justokaysolutions in 816806022

Since there was no response, and the symbol effect isn't working for seemingly no reason, I did it this way instead.

struct SettingsButton: View {
    
    var action: () -> Void
    
    @State private var rotation: Double = 0
    
    var body: some View {
        Button(action: {
            rotation += 360
            action()
        }, label: {
            Image(systemName: "gearshape")
        })
        .rotationEffect(.degrees(rotation))
        .animation(.bouncy.speed(0.3), value: rotation)
    }
}
Accepted Answer

Since there was no response, and the symbol effect isn't working for seemingly no reason, I did it this way instead.

struct SettingsButton: View {
    
    var action: () -> Void
    
    @State private var rotation: Double = 0
    
    var body: some View {
        Button(action: {
            rotation += 360
            action()
        }, label: {
            Image(systemName: "gearshape")
        })
        .rotationEffect(.degrees(rotation))
        .animation(.bouncy.speed(0.3), value: rotation)
    }
}
SwiftUI: Rotate symbolEffect not working
 
 
Q