Demo.swift
ContentView.swift
App.swift
import SwiftUI
struct MagnifyDemo: View {
@State private var scale: CGFloat = 1
var body: some View {
Image(systemName: "photo")
.resizable().scaledToFit().frame(height: 120)
.scaleEffect(scale)
.gesture(
MagnificationGesture()
.onChanged { value in scale = value }
.onEnded { _ in withAnimation(.spring()) { scale = 1 } }
)
}
}
import SwiftUI
struct ContentView: View {
var body: some View { MagnifyDemo() }
}
import SwiftUI
@main
struct MyApp: App {
var body: some Scene {
WindowGroup { ContentView() }
}
}