0

我想创建圆形 uiimageview 动画。当 uiimage 完成后self.left立即再次从 after 调用uiimageview.right。我想调用动画看起来像,但我的动画很糟糕。因为当它完成时self.left,它就开始了self.right。:(但我想看起来像图像:

[ ----(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

 }

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

4

1 回答 1

0

现在建议使用基于块的方法(适用于 iOS4 及更高版本),而不是使用 beginAnimations。

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

options:UIViewAnimationOptionAutoreverse 选项将确保动画前后移动。UIViewAnimationOptionRepeat 选项将使动画继续进行。

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

于 2011-11-24T15:01:23.813 回答