微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ios – UIView块动画从左到右移动视图,从左到右

我不会动画一个像箭头一样的视图,我想让它从左到右,从左到右动画.

下面的代码不起作用,我猜想我需要一个路径,但是不知道如何在UIView块动画中这样做.

[UIView animateWithDuration:.5 delay:0 options:UIViewAnimationoptionRepeat animations:^{
    controller.view.frame = frame1;
    controller.view.frame = frame2;

} completion:^(BOOL finished) {

}];

解决方法

您可以使用UIViewAnimationoptionAutoreverse选项,尝试以下代码
UIView * testView = [[UIView alloc] initWithFrame:CGRectMake(20.0f,100.0f,300.0f,200.0f)];
[testView setBackgroundColor:[UIColor blueColor]];
[self.view addSubview:testView];

[UIView animateWithDuration:0.3f
                      delay:0.0f
                    options:UIViewAnimationoptionRepeat | UIViewAnimationoptionAutoreverse
                 animations:^{
                     [testView setFrame:CGRectMake(0.0f,200.0f)];
                 }
                 completion:nil];

[testView release];

它将重复从右到左,从左到右,顺利地移动.

原文地址:https://www.jb51.cc/iOS/337495.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐