Answer the question
In order to leave comments, you need to log in
How to make a repeating animation in IOS?
Good afternoon!
I read a mountain of posts, but so far I could not figure out how to make a repeating animation.
I need:
1. By clicking on the object - the animation starts
2. The animation is repeated constantly (I want to do something like a bouncing icon in the dock when applications start - this is a sign that the user has selected this object).
3. On the second click on the object, the object returns to its original state and the animation stops
. There is a UIViewAnimationOptionRepeat property, but I don’t understand how to write the code correctly ...
[UIView animateWithDuration:3 delay:0.0
options:(UIViewAnimationOptionAllowUserInteraction |
UIViewAnimationOptionCurveLinear
| UIViewAnimationOptionRepeat)
animations:^(void){
// первая фаза анимации - сдвигаем на несколько поинтов
}
completion:^(BOOL finished){
if(finished){
// вторая фаза анимации - сдвигаем на несколько поинтов обратно
]}
}];
Answer the question
In order to leave comments, you need to log in
The most correct solution would be to use CABasicAnimation (it's pretty easy to google examples). There is a repeatCount property, and there is a value for it HUGE_VALUE , heh
, there is another crutch option
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question