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

Pro SwiftUI Twitter animation example problem

Forums > Books

Hello, I have a question about Pro SwiftUI. I understand how "like" animation works, but I don't understand why it remains visible after user toggles to the "unlike" state afterwards.

If transition code is removed, the states change in this order: 1) Outline heart 2) Filled heart 3) Outline heart

However, if animation is enabled, the last state is different: 1) Outline heart 2) Filledheart 3) Outline heart above filled heart

Can someone explain why?

Btw, to anyone reading this thread and possibly wondering how to make the animation restart multiple times - add id(UUID()) to dismiss the identity of animated object.

   

It starts behaving as it should if I add id(UUID()) to the button itself - well then button gets recreated completely and that makes sense. However, why the contents of the overlay remain visible without this change even though images have different IDs remains mistery to me.

   

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.