Present SwiftUI View Programatically

Is there a way to present a SwiftUI view programatically? I.e. without using a PresentationButton?

Answered by Ugo Arangino in 365404022

Maybe this does help you.


struct Test: View {
    @State var showModal = false
   
    var body: some View {
        Text("example")
            .presentation(showModal ? Modal(Text("detail")) : nil)
    }
}
Accepted Answer

Maybe this does help you.


struct Test: View {
    @State var showModal = false
   
    var body: some View {
        Text("example")
            .presentation(showModal ? Modal(Text("detail")) : nil)
    }
}
Present SwiftUI View Programatically
 
 
Q