36.7 SwiftUI Transitions
A transition occurs in SwiftUI whenever a view is made visible or invisible to the user. To make this process more visually appealing than having the view instantly appear and disappear, SwiftUI allows these transitions to be animated in several ways using either individual effects or by combining multiple effects.
Begin by implementing a simple layout consisting of a Toggle button and a Text view. The toggle is bound to a state property which is then used to control whether the text view is visible. To make the transition more noticeable, animation has been applied to the state property binding:
struct ContentView : View {
@State private var isButtonVisible: Bool = true
var body: some View {
VStack {
Toggle(isOn:$isButtonVisible.animation(
...