blog icon indicating copy to clipboard operation
blog copied to clipboard

How to use popover in SwiftUI

Open onmyway133 opened this issue 2 years ago • 0 comments

In SwiftUI, .popover shows as popover on Mac and iPad, but as .sheet on iPhone (compact size class)

We can use minWidth, minHeight to specify sizes on Mac and iPad. On iPhone, we can check and wrap it inside NavigationView. Setting navigationTitle without being embedded in NavigationView has not effect

``

.popover(isPresented: $showsEdit) {
    EditSnippetView(
        snippet: snippet
    )
    .frame(minWidth: 300, alignment: .topLeading)
    .navigationTitle("Tags")
    .modifier(
        EmbedInNavigationModifier()
    )
}

onmyway133 avatar May 29 '22 20:05 onmyway133