首页 > 其他 > 详细

触摸事件

时间:2015-12-05 11:10:33      阅读:118      评论:0      收藏:0      [点我收藏+]

新建一个uiView  设置类名 

 

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
//NSLog(@"%s",__func__);
// 获取当前触摸点的UITouch对象
UITouch *touch = [touches anyObject];

//获取 当前触摸的位置
CGPoint current = [touch locationInView:touch.view];

//获取 触摸前的位置
CGPoint previous = [touch previousLocationInView:touch.view];

NSLog(@"触摸前的点: %@ 当前触摸点:%@",NSStringFromCGPoint(previous), NSStringFromCGPoint(current));

// 改变位置
CGPoint center = self.center;
center.x += current.x - previous.x;
center.y += current.y - previous.y;

self.center = center;

}

触摸事件

原文:http://www.cnblogs.com/ooo1/p/5021120.html

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