简体   繁体   中英

Finding the swipe gesture is away from circle or towards circle

I have pie menu(or Radial menu). Drawing a gesture on pie should convey the action of moving away from the center of the circle or moving towards the center of the circle. Simply what I want to know is, How to find the swipe gesture is away from the center of the circle or towards the center of the circle in iOS.

Thanks in advance.

The mainstream way of doing this would be to use UISwipeGestureRecogniser . The upside to this class is that you can simply call [gesture locationOfTouch:0 inView:self.view] to get the current location of the user's finger. The downside is that these classes only recognise swipes in a certain direction, and the gesture has to be a swipe, not just any movement. Therefore, if you wanted to recognise touches in all 4 directions you would have to have 4 UISwipeGestureRecognisers

An alternative method is to override touchesBegan: touchesMoved: and touchesEnded: methods in either UIView or UIViewController subclasses. The upside to this method is that you can track any touch at all, where it started, where it's going, etc The downside is that your code becomes much more complex and involved. You can take a look at the Apple Docs where this is concerned.

How to find the swipe gesture is away from the center of the circle or towards the center of the circle in iOS.

This part is easy. Once you've decided on an approach, you can track a user's swipe movement and see if the location of the swipe is drawing closer or further away from the centre point of your circle.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM