Hello,
@State private var animationAmount = 0.0
var body: some View {
Button("Tap Me") {
withAnimation(.interpolatingSpring(stiffness: 5, damping: 1)) {
self.animationAmount += 360
}
}
.padding(50)
. background(Color.red)
.foregroundColor(.white)
.clipShape(Circle())
.rotation3DEffect(.degrees(animationAmount), axis: (x: 0, y: 1, z: 0))
}
}
This code:
Clearly adds 360 degrees to animationAmount on each tap. I expected one full revolution on the first tap, two on the second, three on the third ... etc. Instead it always one full rotation. Similarly, if I use 180 degrees as the animation amount, is always adds 180 degrees. Meaning the first revoution will reverse the direction of the button, and the second one sets it straight again. That's pretty cool - being able to reverse a buton.
But, what if I want to something to spin the once the first time, twice the second, three times the third. Does anyone know of a way to accomplish that?
Would this involve - something we'll cover as we go alone - creating our own modifer/extension and calling that?
Thanks!
Mary