问题
Why does the size animate and not the text with this SwiftUI view? The Text correctly gets bigger and smaller, but the value of the text does not change.
struct ContentView: View {
@State private var isAnimating = 0
var foreverAnimation: Animation {
Animation.linear(duration: 1)
.repeatForever()
}
var body: some View {
Text(isAnimating > 5 ? "Hello" : "Byebye")
.scaleEffect(isAnimating > 5 ? 1.5 : 1)
.animation(foreverAnimation)
.onAppear {
self.isAnimating = 10
}
}
}
来源:https://stackoverflow.com/questions/65282145/why-does-the-size-animate-and-not-the-text-with-this-swiftui-view