From the course: Complete Guide to SwiftUI

Unlock this course with a free trial

Join today to access over 24,600 courses taught by industry experts.

Repeating animation

Repeating animation

- [Instructor] So far we've seen that animation happens on a change in value, and the animation changes from one state to another. However, that's not always the case. You may have an animation that repeats itself or an animation triggered by an action. These need a different approach. Let's rewrite the favorites title view to this as an Hstack adding a heart icon. So let's go up here and we got this favorites here, and I'm going to take that. I'm going to do a control click and embed in Hstack. Unfortunately, it takes the opacity with it and I don't want it there. So I'm going to command X that and command V that outside the Hstack. I want the whole Hstack to be dealing with that opacity. Alright, now inside here I'm going to add, first of all a spacer and then a heart dot fill image. And we'll just go to system name and give it a little bit of padding. The phase animator modifier takes a collection of states and repeats through them. For example, I can make a true and false array…

Contents