Created
November 23, 2019 17:14
-
-
Save a-v-ershov/64cd3c3536a48e2142b862077021a52a to your computer and use it in GitHub Desktop.
MagnificationGesture example
This file contains hidden or 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
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