我有一个问题。我正在尝试在 iOS 中开发一款像 Abacus 这样的游戏。我想在 iOS 中将四张按顺序排列的图像从一个位置水平移动到另一个位置。任何人都可以帮助我请问我如何在 iOS 中执行此操作。我引用这个链接How to move Object from one place to other using Animation in iphone applications 但是使用它我只能水平移动一张图像我想移动四张图像我是怎么做到的。
这是我尝试过的:
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch * touch = [touches anyObject];
CGPoint loc = [touch locationInView:self.view];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
CGRect rect = CGRectMake(loc.x, _img.frame.origin.y, _img.frame.size.height, _img.frame.size.width);
[_img setFrame:rect];
[UIView commitAnimations];
}
最佳答案
将所有图像放在一个 View 中(比如说容器 View ),然后移动容器 View
关于ios - 如何在 ios 中将四个图像从一个位置水平移动到另一个位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31402794/