From the course: Complete Guide to SwiftUI

Unlock this course with a free trial

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

Custom phase animation

Custom phase animation

- [Instructor] Besides repeating animations like our heart, there's one more use for phase animation, custom animation. We have a button to switch between MenuView and MenuGridView in the status bar. Let's animate it with an expanding and contracting effect. So let's head over to StatusBarView. We got it right here on the tab. I'm going to go close up some of this stuff, so we have some room for the moment, since it's white on white for the preview and it's kind of hard to see anyway. But we can just get all our code here, and let's find our presentGrid.toggle, which we have here. We have three phases we're going to put this through. And you make those phases as an enumeration. So I'm going to go first of all back up top here, and outside the struct I'm going to make an enum, and I'm going to call it GridToggleAnimation. And it's important to put CaseIterable, which lets ForEach work on it as though it's an array. So make…

Contents