How to perform operations on each iteration of a UIView animateWithDuration

I am resizing the view using animation, and I need to resize the image in that view at each step of the animation. The image depends on the size of the view, so I want to do this. I tried to do this in the animations: block, but it seems to be called only once, and not for each iteration, as I expected.

How to perform some operations during each iteration of UIView animateWithDuration:animations: Or maybe there is another solution to my problem?

PS I tried to use the completion: block, but it does not solve my problem correctly, since I want to achieve smooth image changes.

+4
source share
1 answer

If I give you a simple answer, the answer will not be ...

but I have an alternative for this to make a function that you can call recursively, like ..

 -(void)animationRecursive { [UIView animateWithDuration:0.001 animations:^{ // Here set frame slide different from last frame use incremental variables // for x,y,width,height //yourImageView.frame = set frame //yourImageView.image = set image } completion:^(BOOL finished) { if(![yourImage.frame isEqualToString NSStringFromCGRect(yourFinalCGRectAfterAnimation)] { [self animationRecursive]; } }]; } 

hope this helps you .............

0
source

Source: https://habr.com/ru/post/1447920/


All Articles