//UItouchcode
// 容许多点触发 [self.view setMultipleTouchEnabled:YES];
// 单击或者移动时会触发这个方法,而且只会调用一次ip
(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ NSLog(@"%s",func);rem
NSLog(@"%@",touches); //
UITouch * touch = [touches anyObject]; NSLog(@"%f",touch.timestamp); // 时间戳it
NSLog(@"%@",touch.view); // 打印手势触发的当前的视图io
NSLog(@"%ld",touch.phase); // 触发时的阶段xevent
NSLog(@"%ld",touch.tapCount); // 点击的次数方法
}im
// 单击或者移动结束会触发这个方法,而且只会调用一次时间戳
// 在屏幕上移动,会屡次调用touch
(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ NSLog(@"%s",func);
UITouch * touch = [touches anyObject];
// 获取上一个点的坐标 // 相对于后面的参数这个view的坐标 CGPoint prePoint = [touch previousLocationInView:self.view];
NSLog(@"%@",NSStringFromCGPoint(prePoint));
// 获取当前点的坐标 CGPoint currentPoint = [touch locationInView:self.view]; NSLog(@"%@",NSStringFromCGPoint(currentPoint));
CGFloat x = currentPoint.x - prePoint.x; CGFloat y = currentPoint.y - prePoint.y; _myView.center = CGPointMake(_myView.center.x+x, _myView.center.y+y);
} // 发生中断(好比有来电时)进行调用
}