说,我有一个宽度为100的UIView
是否可以添加2个这样的手势识别器:
rightTapGesture为视图的右侧50和 leftTapGesture用于其他50个视图?
我不能使用标签式按钮!
答案 0 :(得分:4)
在UIGestureRecognizerDelegate
:
func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool {
switch gestureRecognizer {
case leftTapGesture:
return touch.locationInView(theView).x < 50
case rightTapGesture:
return touch.locationInView(theView).x >= 50
default:
// cannot be here
return false
}
}