//触摸开始
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"touchesBegan");
}
//移动
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch=[touches anyObject];
CGPoint current=[touch locationInView:self];
CGPoint pre=[touch previousLocationInView:self];
CGFloat offsetX=current.x-pre.x;
CGFloat offsetY=current.y-pre.y;
CGPoint center=self.center;
center.x=center.x+offsetX;
center.y=center.y+offsetY;
self.center=center;
}
//结束
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"touchesEnded");
}
//触摸被打断
-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"touchesCancelled");
}