Get your own website
Demo.swift
ContentView.swift
App.swift
 
import SwiftUI

struct MatchedDemo: View {
  @Namespace private var ns
  @State private var showDetail = false
  var body: some View {
    VStack(spacing: 16) {
      if showDetail {
        Circle().matchedGeometryEffect(id: "dot", in: ns).frame(width: 120, height: 120)
      } else {
        Circle().matchedGeometryEffect(id: "dot", in: ns).frame(width: 40, height: 40)
      }
      Button("Toggle") { withAnimation(.spring()) { showDetail.toggle() } }
    }
    .padding()
  }
}

                    
import SwiftUI

struct ContentView: View {
  var body: some View { MatchedDemo() }
}

                    
import SwiftUI

@main
struct MyApp: App {
  var body: some Scene {
    WindowGroup { ContentView() }
  }
}