0

MRE

struct ContentView: View {
    @Namespace var namespace
    @State var show = false
    
    var body: some View {
        VStack {
            Rectangle()
                .fill(.blue)
                .matchedGeometryEffect(id: "blue", in: namespace)
                .frame(width: 100, height: 100)
            
            Button {
                show.toggle()
            } label: {
                Text("show")
            }
        }
        .sheet(isPresented: $show, content: {
            VStack {
                Rectangle()
                    .fill(.blue)
                    .matchedGeometryEffect(id: "blue", in: namespace)
                    .frame(width: 100, height: 100)
                    
                Button  {
                    withAnimation {
                        show.toggle()
                    }
                } label: {
                    Text("dismiss")
                }
                Spacer()
            }
        })
        .padding()
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

I expected the rects to animate but it doesn't?

erotsppa
  • 14,248
  • 33
  • 123
  • 181

0 Answers0