如何设置 UIView 来检测触摸(不是点击)
How to set up a UIView to detect touches (not taps)
我正在努力让我的界面感觉更灵敏。 UIView
在用户触摸时改变颜色,我希望它在触摸视图时就已经这样做了。
我可以实现 UITapGestureRecognizer
但点击不是我想要的,因为它需要触摸在被识别之前结束。
我想这很简单。还是我错了?
我是否创建自定义 UIGestureRecognizer class?
你试过了吗touchedBegan
?
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
if let touch = touches.first {
// ...
}
super.touchesBegan(touches, with: event)
}
我正在努力让我的界面感觉更灵敏。 UIView
在用户触摸时改变颜色,我希望它在触摸视图时就已经这样做了。
我可以实现 UITapGestureRecognizer
但点击不是我想要的,因为它需要触摸在被识别之前结束。
我想这很简单。还是我错了?
我是否创建自定义 UIGestureRecognizer class?
你试过了吗touchedBegan
?
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
if let touch = touches.first {
// ...
}
super.touchesBegan(touches, with: event)
}