我怎样才能在 imageView 上调用 uianimation 看起来像 Circle

发布于 2024-12-18 00:41:50 字数 1400 浏览 1 评论 0原文

我想创建圆形 uiimageview 动画。当 uiimage 在 self.left 处完成时,立即从 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

 }

我该怎么做。谢谢

I want to create circle uiimageview animation. When uiimage finished at self.left immediately calls again from after uiimageview.right. I want to call animation looks like but my animation was bad. Because when it finished self.left, it started self.right. :( But I want to look like image:

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

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

When finished end of image, it coming after.

My code looks like:

 //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

 }

How can i do this. Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一影成城 2024-12-25 00:41:50

现在建议使用基于块的方法(适用于 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 选项将使动画继续播放。

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

Rather than using beginAnimations, it's now recommended to use the block based approach (available on iOS4 and higher).

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

The options:UIViewAnimationOptionAutoreverse option will ensure that the animation goes backwards and forwards. The UIViewAnimationOptionRepeat option will keep the animation going.

Inside the block add your animation code to where the view should move. It'll then move back and forwards to that point.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文