Learn Courses My Dashboard

Slots App Animatoin

Having watched the video SwiftUI Animations - 3 Simple Techniques (ft. Mark Moeykens) it turns out that Apple changed something and this message appears
‘animation’ was deprecated in ios 15.0 use withanimation

Researching it, it appears that animation now requires a 2sd argument called value that conforms to equatable protocol

What I can’t work out is what to use?

There are 3 lines of code like this
the 1st one and last ones of the video

1st one:
I changed it to
.animation(.default, value: animvalue)
— with a line of code added in the declarations: @State private var animvalue = false

Tried a bool, Int… Nope my animations stop working

So please what should it be?

Thank you

And just like that, after searching and posting I resolve it myself which is great

Spoiler Alert - Do not read below if you don’t want the answer

  1. You don’t need any more variables
  2. 1st Line of code in the Video: .animation(.default, value: numbers)
    as numbers change every click
  3. 3rd lines of code in the video
    .animation(.spring(response: 0.7, dampingFraction: 0.3), value: win)
    as win is when you want to spring the Credits
  4. You can now remove the line added above 3 lines
    as effectively Apple force to specify where the animation applies

It works for me