We are a development agency building phenomenal apps.
- 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, autohideIn: 2) {
HStack {
Text("The popup")
}
.frame(width: 200, height: 60)
.background(Color(red: 0.85, green: 0.8, blue: 0.95))
.cornerRadius(30.0)
}
}
}
presented
- binding to determine if the popup should be seen on screen or hidden
view
- view you want to display on your popup
type
- toast, float or default
position
- top or bottom (for default case it just determines animation direction)
animation
- custom animation for popup sliding onto screen
autohideIn
- time after which popup should disappear
To try PopupView examples:
- Clone the repo
https://github.com/exyte/PopupView.git
- Open terminal and run
cd <PopupViewRepo>/Example/
- Run
pod install
to install all dependencies - Run open
PopupViewExample.xcworkspace/
to open project in the Xcode - Try it!
To install PopupView
, simply add the following line to your Podfile:
pod 'ExytePopupView'
To integrate PopupView
into your Xcode project using Carthage, specify it in your Cartfile
github "Exyte/PopupView"
dependencies: [
.package(url: "https://github.com/exyte/PopupView.git", from: "0.0.1")
]
Drop PopupView.swift in your project.
- iOS 13+
- Xcode 11+