NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

'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)?

   

@Bnerd  

all ten values change will trigger the same animation?

   

@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.

   

Hacking with Swift is sponsored by Play

SPONSORED Play is the first native iOS design tool created for designers and engineers. You can install Play for iOS and iPad today and sign up to check out the Beta of our macOS app with SwiftUI code export. We're also hiring engineers!

Click to learn more about Play!

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

Reply to this topic…

You need to create an account or log in to reply.

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.