我想在我的应用程序中放置两个可以移动的 UIImageView。当一个图像与另一个图像接触时,它会触发一个动作,然后将两个图像放回原来的位置。对此有什么建议吗?
我在用
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
// If the touch was in the placardView, move the placardView to its location
if ([touch view] == resultImage) {
CGPoint location = [touch locationInView:self.tabBarController.view];
resultImage.center = location;
return;
}
}
这允许 resultImage 自由移动。我只需要知道如何检测它的任何部分何时接触到另一个图像(它是静止的)并在它发生时执行一个动作,并将 resultImage 返回到它的起始位置。