🔰implicit vs. explicit
implicit: use
view.animation(), SwiftUI will automatically render the animation based on the state changes of the view.explicit: tell SwiftUI what state changes you want to animate inside the
withAnimation()block.
we create an animatable view by calling .animation() on a view. When we create an implicit animation, anytime the view tree is recomputed, changes of animatable properties in this view tree are animated.
Thinking in SwiftUI, Ch. 6: Animations (p.113)
SwiftUI ⟩
Animation (struct)
Animatable (protocol) - describes how to animate a property of a view
View ⟩ Graphics and Rendering ⟩
.animation(_:) - applied to equatable view
.animation(_:value:) - applied to equatable value (non-equatable view)
Last updated
Was this helpful?