與CA

2012-02-20 45 views
2

iphone動畫多張圖片,我有一個UIViewController其中包含16的UIImageView現在我要annimate 4個圖像與核心動畫與CA

任何想法如何做到這一點?

我能夠從動畫一個唯一的下面是我的代碼

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"]; 
+0

什麼阻止你做同樣的與其他圖像 - :

animateWithDuration:delay:options:animations:completion 

您可以通過以下方式來使用它看法? – Till 2012-02-20 11:56:57

回答

0

這裏是我心中的理論解決方案,即在一個循環(1〜[yourImageArray計數])做動態加載的ImageView,使用該循環中的索引從yourImage數組中加載單個圖像。使用imageView上的代碼執行一些動畫。

0

的UIImageViews是的UIView的子類,它有以下方法:

[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];