Skip to content
Khoa Pham@onmyway133

How to show multiple popover in SwiftUI

1 min read

In SwiftUI currently, it’s not possible to attach multiple .popover to the same View. But we can use condition to show different content

struct ClipboardCell: View {
    enum PopoverStyle {
        case raw
        case preview
    }

    @Binding
    var showsPopover: Bool
    @Binding
    var popoverStyle: PopoverStyle

    var body: some View {
        VStack {
            header
            content
                .popover(isPresented: $showsPopover) {
                    switch popoverStyle {
                    case .raw:
                        ViewRawView(item: item)
                    case .preview:
                        PreviewView(item: item)
                    }
                }
            footer
        }
    }
}

Keep reading

Type to search titles and full text.

↑ ↓ move↵ openPagefind