UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

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      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

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.