<!--
{
  "availability" : [
    "iOS: 2.0.0 - 13.0.0",
    "iPadOS: 2.0.0 - 13.0.0",
    "macCatalyst: 13.1.0 - 13.1.0",
    "tvOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIView/setAnimationDelegate(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIView(cm)setAnimationDelegate:"
  },
  "title" : "setAnimationDelegate(_:)"
}
-->

# setAnimationDelegate(_:)

Sets the delegate for any animation messages.

```
class func setAnimationDelegate(_ delegate: Any?)
```

## Parameters

`delegate`

An object that defines the methods registered using the [`setAnimationWillStart(_:)`](/documentation/UIKit/UIView/setAnimationWillStart(_:)) and [`setAnimationDidStop(_:)`](/documentation/UIKit/UIView/setAnimationDidStop(_:)) methods.  The view maintains a strong reference to this object for the duration of the animation.

## Discussion

You can specify an animation delegate in cases where you want to receive messages when the animation starts or stops. After calling this method, you should call the [`setAnimationWillStart(_:)`](/documentation/UIKit/UIView/setAnimationWillStart(_:)) and [`setAnimationDidStop(_:)`](/documentation/UIKit/UIView/setAnimationDidStop(_:)) methods as needed to register appropriate selectors. By default, the animation delegate is set to `nil`.

You primarily use this method to set the delegate for animation blocks created using the begin/commit animation methods. Calling this method from outside an animation block does nothing.

Use of this method is discouraged in iOS 4.0 and later. If you are using the block-based animation methods, you can include your delegate’s start and end code directly inside your block.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)