-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"摸我了");
self.backgroundColor = [UIColor colorWithRed:arc4random() % 256 / 255.0 green:arc4random() % 256 /255.0 blue:arc4random() % 256 /255.0 alpha:1];
//获得当前触摸的点,touches内只有一个触摸对象
UITouch *touch = [touches anyObject];
CGPoint point = [touch locationInView:self];
NSLog(@"%f, %f", point.x,point.y);
self.firstPoint = point;
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"移动了");
//获得当前触摸的点,touches内只有一个触摸对象
UITouch *touch = [touches anyObject];
CGPoint point = [touch locationInView:self];
NSLog(@"%f, %f", point.x,point.y);
self.center = CGPointMake(self.center.x + point.x - self.firstPoint.x , self.center.y + point.y - self.firstPoint.y);
}