Created
May 1, 2024 15:33
-
-
Save takoikatakotako/fec945458cd8d7d5a550908eb7f1924e to your computer and use it in GitHub Desktop.
SwiftUIで画像をピンチで拡大する(MagnificationGesture)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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