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 Essential Developer

SPONSORED From March 20th to 26th, you can join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer!

Click to save your free spot now

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.