SwiftUI + xcode 12
SwiftUI | Action Sheet
Let’s create an ActionSheet with different options using SwiftUI
Difficulty: Beginner | Easy | Normal | Challenging
Environment : Xcode 12 & SwiftUI
Create a new project
Xcode > New Project > App Template > Name it ActionSheet
> SwiftUI App Life Cycle & Interface.
Add the ActionSheet Modifier
Go to your ContentView.swift file and add this State variable:
We will use the State variable to show/hide the ActionSheet, then replace the current Text with the following:
And add the ActionSheet Modifier right below:
This ActionSheet is composed by 3 options, each one open a different URL and there is also a cancel button to close it.
Run your project 🚀
Run your Xcode project and click on the Text, your ActionSheet is there!
Thanks for reading! I’m always happy to have a chat and collaborate at hello@sullivandecarli.com. Consider subscribing to enjoy unlimited access to my articles and all of Medium through my referral link.