[英]Pinch gesture one finger ios
我已经在UILabel上成功添加了捏手势,并且可以增大和减小尺寸。 UILabel还具有平移和旋转手势识别器,并且都可以工作,但是我希望捏手势不仅在两个手指都在对象中时都起作用,而且还希望在一个手指在对象上而另一根在外面时(以防万一)物体太小,无法用2个手指按下。 如果我尝试这样做,它会触发平移手势,而不是捏。
这是将识别器设置为UILabel的函数:
func setGestures(object: UIView){
// recognizer for the dragging move
let panGesture = UIPanGestureRecognizer(target: self, action: #selector(self.wasDragged(gesture:)))
let rotateGesture = UIRotationGestureRecognizer(target: self, action: #selector(self.wasRotated(gesture:)))
var pinchGesture = UIPinchGestureRecognizer(target: self, action: #selector(self.wasPinched(gesture:)))
// set gestures for the text label
object.addGestureRecognizer(panGesture)
object.addGestureRecognizer(pinchGesture)
object.addGestureRecognizer(rotateGesture)
object.isUserInteractionEnabled = true
object.isMultipleTouchEnabled = true
}
有人可以帮忙吗? 谢谢。
将捏手势识别器添加到UIView的超级视图。 如果您有多个必须对捏合做出反应的视图,则需要确定手指所在的两个视图并确定将更改哪个视图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.