A
A
andreys752014-04-28 13:04:40
Objective-C
andreys75, 2014-04-28 13:04:40

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

2 answer(s)
A
An, 2014-04-30
@Flanker_4

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

V
Vanya Ivanov, 2015-01-04
@mr_cloud

https://vk.com/videos-58860049?section=search&z=vi...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question