一瘟檩、手勢
//點擊手勢
UITapGestureRecognizer *tap
//移動手勢
UIPanGestureRecognizer *pan
//添加到視圖上面
[imageView addGestureRecognizer:pan];
#pragma mark - 移動手勢的方法
- (void)pan:(UIPanGestureRecognizer *)pan{
//手勢的生命:began - changed - ended
//判斷手勢的狀態(tài):state
if (pan.state == UIGestureRecognizerStateBegan || pan.state == UIGestureRecognizerStateChanged) {
//1、找到手勢所在的view
UIImageView *imageView = (UIImageView *)pan.view;
//2、獲取手勢移動的位移
CGPoint point = [pan translationInView:self.view];
//3、更改imageView的位置
imageView.center = CGPointMake(imageView.center.x + point.x, imageView.center.y + point.y);
//4悬槽、手勢的位移是會疊加的穗酥,需要把手勢移動的位移歸零
//CGPointZero == CGPointMake(0,0)
[pan setTranslation:CGPointZero inView:self.view];
}
}
//縮放手勢
UIPinchGestureRecognizer *pinch
//旋轉手勢
UIRotationGestureRecognizer *rotation
最后編輯于 :
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者