Skip to content

Instantly share code, notes, and snippets.

@noppefoxwolf
Created October 22, 2019 17:56
Show Gist options
  • Save noppefoxwolf/02fcf065156d632c8b547e13313ff144 to your computer and use it in GitHub Desktop.
Save noppefoxwolf/02fcf065156d632c8b547e13313ff144 to your computer and use it in GitHub Desktop.
Popover dismiss issue
import SwiftUI
struct Item: Identifiable {
let id: String
}
struct ContentView : View {
@State var item: Item? = nil
var body: some View {
Button(action: {
self.item = .init(id: "a")
}) {
Text("Show new view")
}.popover(item: $item, attachmentAnchor: .point(UnitPoint.center), arrowEdge: .bottom) { _ in
HStack {
Button(action: {
self.item = nil
}) {
Text("New Popover")
}
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment