'How to animate a Text view in SwiftUI?
I would like to animate a Text view whenever it is conditionally presented or removed based upon a state variable.
I've tried, to no avail
struct AnimatedText: View {
@State var showingText = false
var body: some View {
VStack {
if showingText {
Text("Hello world")
.animation(.easeInOut, value: showingText)
}
Button("Toggle") {
showingText.toggle()
}
}
}
}
How can I animate the Text view?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|