SwiftUI dismiss modal

前端 未结 13 2209
闹比i
闹比i 2020-11-29 23:23

Since SwiftUI is declarative there is no dismiss methode. How can is add a dismiss/close button to the DetailView?



        
13条回答
  •  余生分开走
    2020-11-30 00:05

    You can implement this.

    struct view: View {
        @Environment(\.isPresented) private var isPresented
    
        private func dismiss() {
            isPresented?.value = false
        }
    }
    

提交回复
热议问题