The double tap, like a single tap, also uses the UITapGestureRecognizer
. You simply set the numberOfTapsRequired
to 2
.
Swift
override func viewDidLoad() {
super.viewDidLoad()
// Double Tap
let doubleTapGesture = UITapGestureRecognizer(target: self, action: #selector(handleDoubleTap))
doubleTapGesture.numberOfTapsRequired = 2
doubleTapView.addGestureRecognizer(doubleTapGesture)
}
// Double tap action
func handleDoubleTap() {
label.text = "Double tap recognized"
}
numberOfTapsRequired
to 3
.