在我看来,我想永远重复一个动画。下面是我的代码:
[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];
Thanks
Swift 4
UIView.animate(withDuration: 100,
delay: 0,
options: [.repeat, .autoreverse, .beginFromCurrentState],
animations: {
}, completion: nil)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)