问题
I'm using UIPanGestureRecognizer
on a project, and I want to take the starting point and the end point.
I tried to do for touchesBegin
, but did not get a code that does what I need.
How can I get the start point and end point of the UIPanGestureRecognizer
?
回答1:
For your case, you might want to include the code inside my function into your IBAction for the panGesture. Here I've created a view, but otherwise you would just be referring to self.view
instead of view
.
var view = UIView()
func panGestureMoveAround(gesture: UIPanGestureRecognizer) {
var locationOfBeganTap: CGPoint
var locationOfEndTap: CGPoint
if gesture.state == UIGestureRecognizerState.Began {
locationOfBeganTap = gesture.locationInView(view)
} else if gesture.state == UIGestureRecognizerState.Ended {
locationOfEndTap = gesture.locationInView(view)
}
}
来源:https://stackoverflow.com/questions/34067087/get-the-start-point-and-end-point-of-the-uipangesturerecognizer-in-swift