如何在ios中水平地将四个图像从一个位置移动到另一个位置

时间:2022-11-15 19:56:56

i have one query. i am try to develop one game like Abacus in iOS. I want to move four images, which are in sequence , from one location to another location horizontally in iOS. Can anyone help me please how i do this in iOS. i refer this link How to move Object from one place to other using Animation in iphone applications but using this i am able to move only one image horizontally i want to move four image how i do this.

我有一个查询。我正在尝试在iOS中开发一个像Abacus这样的游戏。我想要移动四个图像,它们是按顺序排列的,在iOS中水平地从一个位置移动到另一个位置。有人能帮我一下吗?我指的是如何在iphone应用程序中使用动画将对象从一个地方移动到另一个地方,但是使用这个工具,我只能水平移动一个图像,我想移动四个图像。

Here's what I've tried:

这是我试过:

-(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]; 
}

1 个解决方案

#1


0  

Put all your images in a view (lets say container view) and then move the container view

将所有图像放在一个视图中(比如容器视图),然后移动容器视图。

#1


0  

Put all your images in a view (lets say container view) and then move the container view

将所有图像放在一个视图中(比如容器视图),然后移动容器视图。