I want to repeat an animation forever in my view. Below is my code:
[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;
}];
}];
}];
I tried adding option UIViewAnimationOptionRepeat
, but it seems that it only repeats the "animation" part of the most outside layer. I want to repeat the whole set of animation.
And I do not want to use NSTimer
.
Could anyone give me some advice about my problem?? Thanks in advance!