首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >尝试了解UIAnimation路径

尝试了解UIAnimation路径
EN

Stack Overflow用户
提问于 2011-11-20 08:27:55
回答 1查看 317关注 0票数 0

我正在尝试让我的动画在多个生成的路径中移动。我把我的代码写下来了,但是我仍然不明白它有什么问题。

这是我在视图中放置图像的位置

代码语言:javascript
复制
UIImageView *faceAni = [[UIImageView alloc] initWithFrame:CGRectMake(200, 100, 50.0, 50.0)];
        faceAni.animationImages = faces;
        faceAni.animationDuration = 10;
        faceAni.animationRepeatCount = 0;
        [faceAni startAnimating];
        [self addSubview:faceAni];

这就是我尝试让动画在三角形路径坐标中移动的地方。

代码语言:javascript
复制
[UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:1];


        [UIView animateWithDuration:4 
                              delay:0 
                            options:UIViewAnimationOptionRepeat|UIViewAnimationOptionAutoreverse  
                         animations:^{faceAni.transform = CGAffineTransformMakeTranslation(0, 200);} 
                         completion:^(BOOL finished) {

            [UIView animateWithDuration:4 
                                  delay:0 
                                options:UIViewAnimationOptionRepeat|UIViewAnimationOptionAutoreverse  
                             animations:^{faceAni.transform = CGAffineTransformTranslate(faceAni.transform, -100, 0);} 
                             completion:^(BOOL finished) {

                [UIView animateWithDuration:4 
                                      delay:0 
                                    options:UIViewAnimationOptionRepeat|UIViewAnimationOptionAutoreverse 
                                 animations:^{faceAni.transform = CGAffineTransformTranslate(faceAni.transform, 300, 0);} 
                                 completion:NULL];

            }];

        }];

我仍然不明白我的代码出了什么问题。

提前感谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-11-20 10:53:36

如果你描述一下你所看到的行为,可能会有所帮助。不过,作为猜测,您可能不想要传递给每个动画的UIViewAnimationOptionRepeat|UIViewAnimationOptionAutoreverse标志。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8198490

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档