|
So i got to animation section of SwiftUI. I don't understand this .animation modifier, specifically value parameter. in docs it says
but in below program if i give different value to scale and rotation animation, its not working as expected.
I different type of animation to scale and rotation, how to do that? and what is this value parameter really mean? |
|
It's working exactly as you tell it to do. What is your expectation? Pretend you are an animator at Pixar studios. Grab a piece of paper and draw a circle on the left, and a square on the right. 🟡 ➡ 🟨Your job is to animate the circle turning INTO a square. You could put one object in the middle of the paper that is a square with rounded corners. But that's a bad animation. Instead you spend a few hours creating hundreds of inbetween frames where you ever-so-slightly change the rounded circle into straighter and straighter lines eventually forming a square. Changing from one view to another is the animation sequence. In your SwiftUI is the animator in this case, and draws several hundred inbetween frames to make the before and after views magically grow and rotate in your application. Trigger the AnimationBut the question is WHEN do you change from the In your code above, you're telling SwiftUI to start the animation when the Keep CodingIf your code doesn't animate to your expectations, you need to better define your |
|
@Obelix thanks for the explanation. What i wanted to do was have different style of animation for scale change and angle change. e.g: scaling springy animation, and angle change could be easeIn for example. is there any way to achive both animation on single button tap? |
|
Modifiers order with animation applied matters here.
|
SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!
Sponsor Hacking with Swift and reach the world's largest Swift community!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.