Many iOS Apps nowadays use Peek and Pop
to quickly present a Preview of a DetailView
.
However, all I find on the Internet are Tutorials on how to implement this using UIKIT
.
Question: How do I implement the iOS Peek & Pop Functionality
using SwiftUI 2.0
to preview DetailViews
?
There are no Peek and Pop
features or API in the SwiftUI. It is deprecated in iOS 13.
Instead, you can use the contextMenu
which you can add to any SwiftUI view.
Below is the example in SwiftUI :
HStack {
Text("Show Context Menu")
Spacer()
Text("Press & hold")
}
.contextMenu {
Button("Button 1 ") {}
Divider()
Button("Button 2") {}
}