3
3
.
.
3
3
.
.
3
3
G
G
e
e
s
s
t
t
u
u
r
r
e
e
s
s
I
I
n
n
f
f
o
o
[
[
R
R
]
]
Gestures allow Users to interact with Views by using different motions of the fingers.
Gestures can be implemented with following Modifiers: .gesture, .onLongPressGesture & .onTapGesture.
@GestureState is used to update variable from within .updating() method.
Inside the Gesture use self to refer to affected View.
T
T
a
a
p
p
w
w
i
i
t
t
h
h
A
A
n
n
i
i
m
m
a
a
t
t
i
i
o
o
n
n
We use @State Variable which influences .scaleEffect() and which is changed when we Tap on the View.
Tap to change size with animation
struct ContentView: View {
@State private var isPressed = false
var body: some View {
Circle()
.fill(Color.green)
.frame(width: 50, height: 50)
.scaleEffect(isPressed ? 5 : 1)
.animation(.easeInOut)
.onTapGesture{
self.isPressed.toggle()
}
}
}
Initial size Size after tapping (with animation)