UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

'animation' was deprecated in iOS 15.0: Use withAnimation or animation(_:value:) instead.

Forums > SwiftUI

@Pigna  

Hi, I have a problem, how can I substitute .animation() now that is deprecated? I mean I have multiple values that can change, should I really use .animation(value) multiple times? What about I have 10 values? 10 .animation(value)?

1      

@Bnerd  

all ten values change will trigger the same animation?

1      

@Pigna questions new animation syntax:

should I really use .animation(value) multiple times?

If you have ten variables, any one of which could trigger a single animation, consider consolidating them into one computed var. Allow the one computed var to trigger your animation.

But I think one of the benefits of having .animation(value) is that you might have one value that changes a view's background color, another that animates text on screen, and others that move data, or fields into or out of view.

Having different animations based on different values offer more flexibility to designers.

1      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.