首页 > 移动平台 > 详细

ios View拖拽

时间:2016-01-23 17:57:36      阅读:176      评论:0      收藏:0      [点我收藏+]
 1 // 当手指在view上移动的时候调用
 2 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
 3 {
 4     
 5     UITouch *touch = [touches anyObject];
 6     // 0. 获取上一次的位置
 7     CGPoint prePoint = [touch previousLocationInView:self];
 8     
 9     // 1.获取当前的位置
10     CGPoint currentPoint = [touch locationInView:self];
11     
12     CGFloat moveX = currentPoint.x - prePoint.x;
13     CGFloat moveY = currentPoint.y - prePoint.y;
14     
15     // 2.改变当前视图的位置,为手指指定的位置
16     CGPoint temp =  self.center;
17     temp.x += moveX;
18     temp.y += moveY;
19     self.center = temp;
20 
21 }

 

ios View拖拽

原文:http://www.cnblogs.com/PJHome/p/5153434.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!