How can I detect completion of animation caused by CATransaction

I have a CALayer that I just create and add to the subtitle of the main view of the controller of my view in the initWithNibName controller: And then I do the following animation:

  [CATransaction begin];
  [CATransaction setAnimationDuration:2];
  [logoLayer setOpacity:0];
  [CATransaction commit];

How can I find out when this animation is complete? performSelector: delayed for 2 seconds. the approach does not seem “right” for this.

+5
source share
1 answer

According to doc [CATransaction setCompletionBlock:] can be used for what you want.

It says

( ), , , ( ). ​​ , ( ), .

- begin .

[CATransaction setCompletionBlock:^{
    // Action after the animation completion
}];
+22

All Articles