SwiftUI/Responding to events
How to read tap and double-tap gestures
까칠코더
2019. 11. 19. 11:20
반응형
Hacking with Swift 사이트의 강좌 번역본입니다.
[원문 : https://www.hackingwithswift.com/quick-start/swiftui/how-to-read-tap-and-double-tap-gestures]
How to read tap and double-tap gestures
[동영상 강좌 : https://youtu.be/4yY6uci-yLA]
SwiftUI 뷰는 탭 액션을 붙일수 있고, 동작이 시작(triggered)되기 전에 수신해야하는 탭의 갯수를 지정할 수 있습니다.
예를들어, 탭할때 메시지를 출력하는 텍스트 뷰를 만듭니다.
Text("Tap me!")
.onTapGesture {
print("Tapped!")
}
그리고 2번(double) 탭 할때 메시지를 출력하는 이미지 뷰를 만듭니다.
Image("example-image")
.onTapGesture(count: 2) {
print("Double tapped!")
}
반응형