Xcode Beta 6中的SwiftUI模态?

Jac*_*ord 6 xcode ios swift swiftui xcode11

以前在SwiftUI(Xcode Beta 5)中,一种模式的工作方式如下:

struct ContentView: View {

    @State var modalIsPresented: Bool = false

    var body: some View {

        Button(action: {

            self.modalIsPresented = true

        }) {

            Text("Show modal")

        }

        .sheet(isPresented: $modalIsPresented, content: {

            ModalView()

        })

    }

}

struct ModalView: View {

    @Environment(\.presentationMode) var presentationMode

    var body: some View {

        Button(action: {

            self.presentationMode.value.dismiss()

        }) {

            Text("Hide modal")

        }

    }

}
Run Code Online (Sandbox Code Playgroud)

但是现在在Xcode Beta 6中,我找不到消除模态的方法。不再具有的value属性presentationMode,而其他属性似乎没有可用的任何有用方法。

如何在Xcode Beta 6中关闭SwiftUI模式?

sze*_*ian 7

在Xcode Beta 6中,使用wrappedValue代替似乎可以:

self.presentationMode.wrappedValue.dismiss()
Run Code Online (Sandbox Code Playgroud)