Maybe I should just move along because the code is working but I have so many questions where I don't understand.
So, objective is to just have an image rotating.
Code I found informed me that .animation has been deprecated.
So here's some stuff I discovered that doesn't make sense to me.
This code works, but (1). why do I have to do onAppear? (without onAppear the image doesn't rotate).
@State private var isRotating = true
var body: some View {
ZStack {
Image("Layer0")
.resizable()
.frame(width: 100, height: 100)
.rotationEffect(.degrees(isRotating ? 360 : 0))
// .animation(Animation.linear(duration: 1).repeatForever(), value: isRotating)
.animation(.linear(duration: 10).repeatForever(autoreverses: false), value: isRotating)
}
.onAppear {
isRotating = false
}
}
Then, this is crazy to me, if I change the var to false and the isRotating to true it just reverses from clockwise to counter-clockwise.
(2). I would think saying isRotating = false would mean No animation. Why does it reverse the direction?