📜  swift uiview 添加点击手势 - Swift 代码示例

📅  最后修改于: 2022-03-11 15:00:57.689000             🧑  作者: Mango

代码示例1
let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:)))
myView.addGestureRecognizer(tap)

// Then, you should implement the handler, which will be called each time when a tap event occurs:

@objc func handleTap(_ sender: UITapGestureRecognizer? = nil) {
    // handling code
}