使用CA在iphone中设置多个图像的动画

使用CA在iphone中设置多个图像的动画,iphone,core-animation,Iphone,Core Animation,我有一个UIViewController,其中包含16个UIImageView,现在我必须将4个图像与核心动画匹配 你知道怎么做吗 我能够动画的唯一下面是我的代码 CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"position"]; anim.fromValue = [NSValue valueWithCGPoint:CGPointMake(100, 100)]; anim.toValue = [NSV

我有一个UIViewController,其中包含16个UIImageView,现在我必须将4个图像与核心动画匹配

你知道怎么做吗

我能够动画的唯一下面是我的代码

CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"position"];
anim.fromValue  = [NSValue valueWithCGPoint:CGPointMake(100, 100)];
anim.toValue    = [NSValue valueWithCGPoint:CGPointMake(200, 200)];
anim.duration   = 1.5f;
anim.repeatCount =1;
anim.removedOnCompletion = YES;
anim.autoreverses = YES;
anim.repeatCount = 10;
anim.timingFunction = [CAMediaTimingFunction        
functionWithName:kCAMediaTimingFunctionEaseIn];
[imgview.layer  addAnimation:anim forKey:@"position"];

在我看来,这是一个理论解决方案,在从(1到[yourImageArray count])的循环中,动态加载imageView,使用循环中的索引从图像数组加载单个图像。使用imageView上的代码执行一些动画。

我认为这是一个理论解决方案,在从(1到[yourImageArray count])的循环中,动态加载imageView,使用该循环中的索引从图像数组加载单个图像。使用imageView上的代码执行一些动画。

UIImageView是UIView的子类,具有以下方法:

animateWithDuration:delay:options:animations:completion
您可以通过以下方式使用它:

[UIView animateWithDuration:1.5f
                          delay:0.0f
                        options:UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat
                     animations:^{
[UIView setAnimationRepeatCount:10];
[imgview1 setCenter:CGPointMake(200,200)];
[imgview2 setCenter:CGPointMake(300,200)];
[imgview3 setCenter:CGPointMake(400,200)];
[imgview4 setCenter:CGPointMake(500,200)];
};
                     completion:nil];

UIImageView是UIView的子类,具有以下方法:

animateWithDuration:delay:options:animations:completion
您可以通过以下方式使用它:

[UIView animateWithDuration:1.5f
                          delay:0.0f
                        options:UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat
                     animations:^{
[UIView setAnimationRepeatCount:10];
[imgview1 setCenter:CGPointMake(200,200)];
[imgview2 setCenter:CGPointMake(300,200)];
[imgview3 setCenter:CGPointMake(400,200)];
[imgview4 setCenter:CGPointMake(500,200)];
};
                     completion:nil];

是什么阻止您对其他图像视图执行相同操作?是什么阻止您对其他图像视图执行相同操作?