手勢小記

一:.拖動手勢
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];

}


歡迎補充,,,,

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章