Monday, November 9, 2026
HomeiOS Developmentios - matchedGeometryEffect simply jumps and does not animate

ios – matchedGeometryEffect simply jumps and does not animate

[ad_1]

I’m making an attempt to animate a picture from the centre to the highest of my display with matchedGeometryEffect. Nevertheless, it simply jumps. This can be a simplified model of my view, which is basically what I am making an attempt to do:

struct MyView: View {
  @Namespace non-public var animation
  @State non-public var showSplash = true

  var physique: some View {
    if showSplash {
      Picture("SplashIcon")
        .matchedGeometryEffect(id: "icon", in: animation)
        .body(maxWidth: .infinity)
        .process {
          attempt? await Activity.sleep(nanoseconds: 1_500_000_000)
          withAnimation {
            showSplash.toggle()
          }
        }
    } else {
      VStack {
        Picture("SplashIcon")
          .matchedGeometryEffect(id: "icon", in: animation)
          .body(maxWidth: .infinity)
        Spacer()
      }
    }
  }

How do I repair this?

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments