Search code examples
cocoa-touchioscore-animation

Core animation equivalent for built-in UIView animation


I'm looking for an equivalent core animation for the following UIView animation?

[UIView animateWithDuration:0.25 animations:^(void) {
                cell.frame = newCellFrame;

            } completion:^(BOOL finished) {
                [UIView animateWithDuration:0.25 animation:^(void) {
                    cell.frame = finalCellFrame;
                }];                    
            }];

What I would like to know in particular is how you mimic the "completion" part of this animation with core animation. Is the only option to use core animation delegation or is there a solution as elegant as the above code snippet?


Solution

  • In CoreAnimation it's done with delegates. You can set a delegate on your CAAnimation/CABasicAnimation instance, and the animation will make animationDidStart: and animationDidStop:finished: callbacks to you.