Methods your app can implement to respond when animations start and stop.
Mac Catalyst 13.0+
You can use an animation delegate to execute additional logic when an animation starts or ends. For example, you may want to remove a layer from its parent once a fade out animation has completed.
Listing 1 shows code taken from a class that implements CAAnimationDelegate and has had a layer, named sublayer, added to its layer. The fadeOut function animates the opacity of sublayer and, once the animation has completed, animationDidStop(_:finished:) removes it from its superlayer.