- (void)doAnimation
{
[UIView animateWithDuration:12.8f
delay: 0.0
options: UIViewAnimationCurveLinear
animations:^{
frame = label1.frame;
frame.origin.x = -12;
label1.frame = frame;
}
completion:^(BOOL finished){
if(keepAnimating) {
[self doAnimation];
}
}];
}
In the title:
BOOL keepAnimating;
To start the animation:
keepAnimating = YES;
[self doAnimation]
To stop the animation:
keepAnimating = NO;
This solution uses block animation methods in UIView. Regarding the old set of animation methods ([UIView beginAnimations], etc.), the reference to the UIView class states:
Using the methods in this section is not recommended in iOS 4 and later. Use block-based animation methods instead.
source
share