iOS   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何在iOS中永远重复动画?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
参见英文答案 > How to make UIView animation sequence repeat and autoreverse                                    3个
我想在我看来永远重复一个动画.以下是我的代码

[UIView animateWithDuration:0.5f
        delay:0.49f
        options:UIViewAnimationOptionCurveEaseInOut
        animations:^{
        //for IMMERSE
        [_pic2 setAlpha:1.0f];
         _view1_immerse=_pic2.frame;
         _view1_immerse.origin.x = ([UIScreen mainScreen].bounds.size.width-_view1_immerse.size.width)/2;
         self.pic2.frame=_view1_immerse;
         }
         completion:^(BOOL finished){
         [UIView animateWithDuration:0.5f delay:0.49f options:UIViewAnimationOptionCurveEaSEOut animations:^{
         _view1_immerse=_pic2.frame;
         _view1_immerse.origin.x = [UIScreen mainScreen].bounds.size.width;
         self.pic2.frame=_view1_immerse;
         [_pic2 setAlpha:0.0];
         } completion:^(BOOL finished){
         [UIView animateWithDuration:0.0f animations:^{
         _view1_immerse=_pic2.frame;
         _view1_immerse.origin.x = -_view1_immerse.size.width;
         self.pic2.frame=_view1_immerse;
                                     }];
                                 }];
                             }];

我尝试添加选项UIViewAnimationOptionRepeat,但它似乎只重复最外层的“动画”部分.我想重复一整套动画.

而且我不想使用NSTimer.
谁能给我一些关于我的问题的建议?提前致谢!

解决方法

您可以查看以下代码以重复动画.

[UIView animateWithDuration:1.0f
                  delay:0.0f
                options: UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse | UIViewAnimationOptionBeginFromCurrentState
             animations: ^(void){self.view.center = CGPointMake(0,200);}
             completion:NULL];

谢谢

斯威夫特4

UIView.animate(withDuration: 100,delay: 0,options: [.repeat,.autoreverse,.beginFromCurrentState],animations: {

    },completion: nil)

大佬总结

以上是大佬教程为你收集整理的如何在iOS中永远重复动画?全部内容,希望文章能够帮你解决如何在iOS中永远重复动画?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: