From the course: iOS Development Tips

Unlock this course with a free trial

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

SwiftUI transitions for modal views

SwiftUI transitions for modal views

From the course: iOS Development Tips

SwiftUI transitions for modal views

- [Instructor] Most code needs modal views for alerts, settings, and their functions. Currently, in SwiftUI, you need sheets for modals. However, sheets only have one transition. Let's look at another way to use custom transitions and views to handle modals. So, download the exercise file. You have a simple app with a button and I'm going to go put this on live preview, and hit the modal button. And as you see, I got a small modal that pops up underneath and I've got a button to dismiss it, which is all fine and good. Now I want to add some transitions 'cause that's kind of boring. So first thing you want to do is add a animation. So I'm going to go to where the Vstack starts, which is right here and add some animation with an animation modifier, and we'll keep it simple. We'll just use an easeIn. And that's all we're going to do with that. And we can try it again. And now it fades in and then I hit dismiss…

Contents