<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIDynamicBehavior",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIDynamicBehavior"
  },
  "title" : "UIDynamicBehavior"
}
-->

# UIDynamicBehavior

An object that confers a behavioral configuration on one or more dynamic items, for their participation in 2D animation.

```
@MainActor class UIDynamicBehavior
```

## Overview

A *dynamic item* is any iOS or custom object that conforms to the [`UIDynamicItem`](/documentation/UIKit/UIDynamicItem) protocol. The [`UIView`](/documentation/UIKit/UIView) and [`UICollectionViewLayoutAttributes`](/documentation/UIKit/UICollectionViewLayoutAttributes) classes implement this protocol starting in iOS 7.0. You can implement this protocol to use a dynamic animator with custom objects for such purposes as reacting to rotation or position changes computed by an animator—an instance of the [`UIDynamicAnimator`](/documentation/UIKit/UIDynamicAnimator) class.

This parent class, [`UIDynamicBehavior`](/documentation/UIKit/UIDynamicBehavior), is inherited by the primitive dynamic behavior classes [`UIAttachmentBehavior`](/documentation/UIKit/UIAttachmentBehavior), [`UICollisionBehavior`](/documentation/UIKit/UICollisionBehavior), [`UIGravityBehavior`](/documentation/UIKit/UIGravityBehavior), [`UIDynamicItemBehavior`](/documentation/UIKit/UIDynamicItemBehavior), [`UIPushBehavior`](/documentation/UIKit/UIPushBehavior), and [`UISnapBehavior`](/documentation/UIKit/UISnapBehavior).

You can subclass [`UIDynamicBehavior`](/documentation/UIKit/UIDynamicBehavior). By using the [`addChildBehavior(_:)`](/documentation/UIKit/UIDynamicBehavior/addChildBehavior(_:)) method in an instance of this class or in a custom subclass, you can create composite behaviors of your own design.

When you subclass [`UIDynamicBehavior`](/documentation/UIKit/UIDynamicBehavior), you typically need to provide one or more initializers, along with other housekeeping methods such as those implemented in the iOS primitive dynamic behaviors.

To perform per-step logic in a dynamic animation, provide a block object using the [`action`](/documentation/UIKit/UIDynamicBehavior/action) property.

To access the dynamic animator that a dynamic behavior is associated with, use the [`dynamicAnimator`](/documentation/UIKit/UIDynamicBehavior/dynamicAnimator) property. To respond to a dynamic behavior being added to or removed from a dynamic animator, implement the [`willMove(to:)`](/documentation/UIKit/UIDynamicBehavior/willMove(to:)) method.

## Topics

### Configuring a dynamic behavior

[`action`](/documentation/UIKit/UIDynamicBehavior/action)

The block you want to execute during dynamic animation.

[`-  addChildBehavior:`](/documentation/UIKit/UIDynamicBehavior/addChildBehavior(_:))

Adds a dynamic behavior, as a child, to a custom dynamic behavior.

[`childBehaviors`](/documentation/UIKit/UIDynamicBehavior/childBehaviors)

Returns the array of dynamic behaviors that are children of a custom dynamic behavior.

[`-  removeChildBehavior:`](/documentation/UIKit/UIDynamicBehavior/removeChildBehavior(_:))

Removes a child dynamic behavior from a custom dynamic behavior.

### Responding to changes in the behavior tree

[`dynamicAnimator`](/documentation/UIKit/UIDynamicBehavior/dynamicAnimator)

The dynamic animator that the dynamic behavior is associated with.

[`-  willMoveToAnimator:`](/documentation/UIKit/UIDynamicBehavior/willMove(to:))

Called when the dynamic behavior is added to, or removed from, a dynamic animator.

## Relationships

### Conforms To

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Sendable`](/documentation/Swift/Sendable)

[`Hashable`](/documentation/Swift/Hashable)

### Inherited By

[`UIAttachmentBehavior`](/documentation/UIKit/UIAttachmentBehavior)

[`UISnapBehavior`](/documentation/UIKit/UISnapBehavior)

[`UIGravityBehavior`](/documentation/UIKit/UIGravityBehavior)

[`UIPushBehavior`](/documentation/UIKit/UIPushBehavior)

[`UIFieldBehavior`](/documentation/UIKit/UIFieldBehavior)

[`UIDynamicItemBehavior`](/documentation/UIKit/UIDynamicItemBehavior)

[`UICollisionBehavior`](/documentation/UIKit/UICollisionBehavior)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)