How to stop UIPanGestureRecognizer when object moved to certain frame

后端 未结 3 2110
逝去的感伤
逝去的感伤 2021-02-07 09:21

I have an object of image type which I am moving using UIPanGestureRecognizer, and I need to stop recognizing the UIPanGestureRecognizer when the object reaches a certain frame.

3条回答
  •  情歌与酒
    2021-02-07 09:48

    UIGestureRecognizers have an enabled property. Documentation:

    Disables a gesture recognizers so it does not receive touches. The default value is YES. If you change this property to NO while a gesture recognizer is currently recognizing a gesture, the gesture recognizer transitions to a cancelled state.

    EDIT:

    Just set the enabled property to NO.

    gestureRecognizer.enabled = NO;
    

提交回复
热议问题