我正在使用UIPanGestureRecognizer
一个项目,我想采取起点和终点.
我试图做touchesBegin
,但没有得到我需要的代码.
我怎样才能得到起点和终点UIPanGestureRecognizer
?
对于您的情况,您可能希望将我的函数中的代码包含在panGesture的IBAction中.在这里,我创建了一个视图,但除此之外你只是指self.view
而不是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) } }