AlertToast
AlertToast copied to clipboard
Create Example Project
I checked both article and project. No example project. I would recommend adding project used to create demo screens.
You don't really need examples, this is extremely simple, creating one works like popovers, but I'm going to show you an example:
// Init state variable that tracks if toast is shown
@State var toastShown: Bool = false
// Create a button somewhere in view that will show that toast when clicked
Button("Show toast") {
toastShown = true
}
// Create that toast somewhere in view like you would create a popover
.toast(isPresenting: $toastShown) {
AlertToast(
displayMode: .hud, type: .regular, title: "Toast title")
}
Don't just ctrl + c ctrl + v this code, you need to place that button and that toast inside view.
If you want to modify how it looks, then change arguments inside AlertToast.