---
title: CAAnimationDelegate
framework: quartzcore
role: symbol
role_heading: Protocol
path: quartzcore/caanimationdelegate
---

# CAAnimationDelegate

Methods your app can implement to respond when animations start and stop.

## Declaration

```swift
protocol CAAnimationDelegate : NSObjectProtocol
```

## Overview

Overview 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. The following example 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. func fadeOut() {     let fadeOutAnimation = CABasicAnimation()     fadeOutAnimation.keyPath = "opacity"     fadeOutAnimation.fromValue = 1     fadeOutAnimation.toValue = 0     fadeOutAnimation.duration = 0.25          fadeOutAnimation.delegate = self          sublayer.add(fadeOutAnimation,                       forKey: "fade") }      func animationDidStop(_ anim: CAAnimation, finished flag: Bool) {     sublayer.removeFromSuperlayer() }

## Topics

### Customizing Start and Stop Times

- [animationDidStart(_:)](quartzcore/caanimationdelegate/animationdidstart(_:).md)
- [animationDidStop(_:finished:)](quartzcore/caanimationdelegate/animationdidstop(_:finished:).md)

## Relationships

### Inherits From

- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Animation

- [CAAnimation](quartzcore/caanimation.md)
- [CAPropertyAnimation](quartzcore/capropertyanimation.md)
- [CABasicAnimation](quartzcore/cabasicanimation.md)
- [CAKeyframeAnimation](quartzcore/cakeyframeanimation.md)
- [CASpringAnimation](quartzcore/caspringanimation.md)
- [CATransition](quartzcore/catransition.md)
- [CAValueFunction](quartzcore/cavaluefunction.md)
