- Put all your body code into a ZStack
- Add a binding bool to control popup presentation state
- Add
.popup
modifier to your ZStack
@State var showingPopup = false
struct ContentView: View {
var body: some View {
ZStack {
// your view
}
.popup(isPresented: $showingPopup, animation: Animation.spring(), autohideIn: 2) {
Toast(image: "airpodspro", title: "AirPods Pro", subtitle: "Connected")
}
}
}
presented
- binding to determine if the popup should be seen on screen or hidden
view
- view you want to display on your popup
animation
- custom animation for popup sliding onto screen
autohideIn
- time after which popup should disappear
dependencies: [
.package(url: "https://github.com/twentyone24/floaters.git", from: "0.0.1")
]