设置是否支持多点触摸.默认为单点触摸
self.multipleTouchEnabled = YES;
碰撞检测:过程
UIApplication --> UIWindow --> UIviewController -->视图控制器View --> 父视图 --> 子视图
事件响应
子视图 --> 父视图 --> 视图控制器 --> UIviewController --> UIWindow --> UIApplication
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
NSArray * arr = [touches allObjects];
UITouch * touch = arr[0];
CGPoint Point_1 = [touch locationInView:self];
if ([arr count] == 2) {
UITouch * touch1 = arr[1];
CGPoint Point_2 = [touch1 locationInView:self];
}
获取手指对象
UITouch * touch = [touches anyObject];
获取移动之后手指在视图上的位置
CGPoint point = [touch locationInView:self.superview];
self.center = CGPointMake(point.x, point.y);
CGPoint currenPoint = [touch locationInView:self];
获取移动之前和移动之后的变化量
CGFloat dx = currenPoint.x - _pervPoint.x;
CGFloat dy = currenPoint.y - _pervPoint.y;
self.center = CGPointMake(self.center.x + dx, self.center.y+dy);
}
版权声明:本文为博主原创文章,未经博主允许不得转载。