animation(_:body:)
Applies the given animation to all animatable values within the body closure.
Declaration
nonisolated func animation<V>(_ animation: Animation?, @ViewBuilder body: (PlaceholderContentView<Self>) -> V) -> some View where V : View
Discussion
Any modifiers applied to the content of body will be applied to this view, and the animation will only be used on the modifiers defined in the body.
The following code animates the opacity changing with an easeInOut animation, while the contents of MyView are animated with the implicit transaction’s animation:
MyView(isActive: isActive)
.animation(.easeInOut) { content in
content.opacity(isActive ? 1.0 : 0.0)
}