Skip to content

Instantly share code, notes, and snippets.

@takoikatakotako
Created May 1, 2024 15:33
Show Gist options
  • Save takoikatakotako/fec945458cd8d7d5a550908eb7f1924e to your computer and use it in GitHub Desktop.
Save takoikatakotako/fec945458cd8d7d5a550908eb7f1924e to your computer and use it in GitHub Desktop.
SwiftUIで画像をピンチで拡大する(MagnificationGesture)
import SwiftUI
struct ContentView: View {
@State var scale: CGFloat = 1.0
var body: some View {
Image(.icon)
.resizable()
.scaleEffect(scale)
.frame(width: 200, height: 200)
.gesture(MagnificationGesture()
.onChanged { value in
scale = value.magnitude
}
)
}
}
#Preview {
ContentView()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment