Skip to content

Instantly share code, notes, and snippets.

@ershovio
Created November 23, 2019 17:14
Show Gist options
  • Save ershovio/64cd3c3536a48e2142b862077021a52a to your computer and use it in GitHub Desktop.
Save ershovio/64cd3c3536a48e2142b862077021a52a to your computer and use it in GitHub Desktop.
MagnificationGesture example
struct MagnificationGestureExample: View {
@State var rectangleScaleEffect: CGFloat = CGFloat(1)
var body: some View {
// MagnificationGesture creation
let magnificationGesture = MagnificationGesture()
// Scale effect recalculation for the rectangle
.onChanged { value in
self.rectangleScaleEffect = value
}
return Rectangle()
.foregroundColor(.green)
.cornerRadius(40)
// Change scale effect
.scaleEffect(rectangleScaleEffect)
.frame(width: 200, height: 100, alignment: .center)
// Add the magnificationGesture to this view
.gesture(magnificationGesture)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment