您好,登录后才能下订单哦!
UIPanGestureRecognizer * panGesture = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(panGesture:)];
[redView addGestureRecognizer:panGesture];
[panGesture release];
- (void)panGesture:(UIPanGestureRecognizer *)panGesture
{
CGPoint point = [panGesture translationInView:panGesture.view];
panGesture.view.transform = CGAffineTransformMakeTranslation(point.x, point.y);
panGesture.view.transform = CGAffineTransformTranslate(panGesture.view.transform, point.x, point.y);
将之前增量清零
[panGesture setTranslation:point inView:panGesture.view];
获取的是手指位置的改变量 , 存储在x轴以及y轴的改变量
CGPoint point = [panGesture translationInView:panGesture.view];
panGesture.view.center = CGPointMake(panGesture.view.center.x+ point.x,panGesture.view.center.y+ point.y);
将之前的增量清零 重置之前的增量
[panGesture setTranslation:CGPointZero inView:panGesture.view];
panGesture.view.backgroundColor = [UIColor random];
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。