//单击手势
let tap = UITapGestureRecognizer(target: self, action: #selector(tapAct))
tap.numberOfTapsRequired = 1
contentView.addGestureRecognizer(tap)
//双击手势
let tap2 = UITapGestureRecognizer(target: self, action: #selector(tap2Act))
tap2.numberOfTapsRequired = 2
contentView.addGestureRecognizer(tap2)
//关键代码
tap.require(toFail: tap2)
@objc private func tapAct() {
print("tap act....")
}
@objc private func tap2Act() {
print("tap 2 act....")
}
网友评论