如何将 GeometryProxy 添加到 PreviewProvider

Joe*_*ini 1 swiftui

好的,我将 GeometryProxy 传递到结构视图主体中,我不知道如何执行此操作,但仍然使用 PreviewProvider 有人可以帮助我吗?

struct MyView: View {

    let geometry: GeometryProxy

    var body: some View {
        VStack {
           .... More Code Here
        }
    }
}

struct MyView_Previews: PreviewProvider {
    static var previews: some View {
        Group {
            // This is where Im having trouble. I have no idea how to pass in GeometryProxy
            MyView()
        }
    }
Run Code Online (Sandbox Code Playgroud)

小智 8

它应该是这样的:

struct MyView_Previews: PreviewProvider {
    static var previews: some View {
        GeometryReader { proxy in
            MyView(proxy: proxy)
        }
     }
 }
Run Code Online (Sandbox Code Playgroud)