I'm a newbie to SwiftUI. I wrote this simple code:
struct ani_repeat: View {
@State private var xv = false
var body: some View {
VStack {
Text("Hello, World!")
.scaleEffect(xv ? 1.5 : 1)
Text("\(xv ? "T" : "F")")
}
.onTapGesture {
withAnimation(Animation.spring().repeatForever()){
self.xv.toggle()
}
}
}
}
When I first tap the text, it scales repeatedly, and the second line alternates between "T" and "F".
When I tap the text a second time, the first line remains at its original size, but the second line still alternates between "T" and "F".
I don't understand why the first line doesn't scale again, despite toggling xv.
I asked ChatGPT for help, but I still don't understand. My English is not good(for Apple Documents) and I can't buy SwiftUI books where I am.