-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event touchesForView:self.view] anyObject];
CGPoint point = [touch locationInView:self.view];
basketView.center = CGPointMake(point.x, point.y);
}
我目前有这个代码可以让用户用手指移动图像。但是,如果我想在屏幕上添加多个可移动图像(比如我也希望能够移动UIImages basketView2和basketView3),我将如何更改代码以允许此操作?
答案 0 :(得分:1)
您只需要修改以下代码
UITouch *touch = [[event touchesForView:self.view] anyObject];
CGPoint point = [touch locationInView:self.view];
UIImageView *currentView=(UIImageView *)touch.view;
currentView.center = CGPointMake(point.x, point.y);