TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

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.

3      

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.

3      

Hacking with Swift is sponsored by Superwall.

SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.

Learn More

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.