2011-11-24 58 views
0

我想创建圆形uiimageview动画。当在self.left完成uiimage立即从uiimageview.right后调用。我想调用动画看起来像但我的动画是不好的。因为当它完成self.left时,它开始self.right。 :(但我希望能像图像:如何在imageView上调用uianimation看起来像Circle

[ ----(end of image)---------  --------(start of image)] 

Me. I did it. 
[ -----(end of image)----------  ] 

当完成图像的结束,这之后到来

我的代码如下所示:

//for start 
    [UIView beginAnimations:nil context:nil]; 

    imageView.left = - imageView.width; 
    // imageView2.left = - imageView.width; 


    [UIView setAnimationDuration:140.0]; 
    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDidStopSelector:@selector(moveToLeft:finished:context:)]; 
    [UIView commitAnimations]; 




-(void)moveToLeft:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context 
{ 
    imageView.left = self.right; 
    imageView2.left = self.right + 3600; 




    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationDuration:140.0]; 
    [UIView setAnimationDelegate:self]; 
    imageView.left = -imageView.right; 

    imageView2.left = -imageView2.right; 





    // imageView.left = - imageView.width; 
    [UIView setAnimationDidStopSelector:@selector(moveToLeft:finished:context:)]; 
    [UIView commitAnimations]; 



    // imageView.frame.origin.x = imageView.left - self.right 

} 

我怎样才能做到这一点感谢

回答

0

不是使用beginAnimations,而是现在推荐使用基于块的方法(可在iOS4和更高版本上获得)

[UIVIew animateWithDuration:140.0 delay:0.0 
        options:UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat 
       animations:^(void) { 
        imageView.frame = CGRectMake(*Add Final position here*); 
       } 
       completion:^(BOOL finished) {}]; 

选项:UIViewAnimationOptionAutoreverse选项将确保动画向后和向前移动。 UIViewAnimationOptionRepeat选项将保持动画继续。

在块内部添加您的动画代码到视图应该移动的位置。然后它会前后移动到那一点。

+0

哦,既然你是新来的,你应该知道,如果这解决了你的问题,你应该接受使用左侧刻度的答案。 – tarmes

相关问题