'animation' was deprecated in iOS 15.0
I used a very simple animation that opens a button bar in a very soft an smooth way:
.animation(.spring(response:1.5))
I want to update my app to iOS15 and 'animation' was deprecated in iOS 15.0
So I tried to change my animation to:
.animation(.spring(response:1.5), value: 0)
or something like:
.animation(.spring(response: 1.5, dampingFraction: 2.5, blendDuration: 2.5), value: 10)
however, the new animation pops up very fast and the smooth effect is gone.
Does anyone know how to bring my little spring animation to iOS 15?
Solution 1:
When using the animation
modifier with value
, the animation only runs when the value
changes.
So for example, if the animation should be triggered when a boolean value is toggled, you would do the following:
@State private var showThing = false
/* ... */
.animation(.spring(response: 1.5), value: showThing)
When running showThing.toggle()
, you will see this animation take affect.
Documentation for animation(_:value:)
:
Applies the given animation to this view when the specified value changes.
A view that applies
animation
to this view whenevervalue
changes.
value
: A value to monitor for changes.