一:.拖動手勢
1.獲取手勢所在的視圖
-(void)panAction:(UIPanGestureRecognizer *)gesture {
UIView *bgView = gesture.view;//bgView就是添加手勢的視圖
}
2.獲取手勢接觸屏幕的初始座標
-(void)panAction:(UIPanGestureRecognizer *)gesture {
CGPoint point = [gesture locationInView:self.view];
}
二:touch事件(接觸屏幕時響應的事件)
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
//獲取接觸屏幕時的初始座標
UITouch *touch = touches.anyObject;
CGPoint point = [touch locationInView:self.view];
}
歡迎補充,,,,