<!--
{
  "availability" : [
    "macOS: 10.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSAnimationContext",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSAnimationContext"
  },
  "title" : "NSAnimationContext"
}
-->

# NSAnimationContext

An animation context, which contains information about environment and state.

```
class NSAnimationContext
```

## Overview

[`NSAnimationContext`](/documentation/AppKit/NSAnimationContext) is analogous to <doc://com.apple.documentation/documentation/QuartzCore/CATransaction> and is similar in overall concept to [`NSGraphicsContext`](/documentation/AppKit/NSGraphicsContext). Each thread maintains its own stack of nestable [`NSAnimationContext`](/documentation/AppKit/NSAnimationContext) instances, with each new instance initialized as a copy of the instance below (so, inheriting its current properties).

Multiple [`NSAnimationContext`](/documentation/AppKit/NSAnimationContext) instances can be nested, allowing a given block of code to initiate animations using its own specified duration without affecting animations initiated by surrounding code.

```objc
[NSAnimationContext beginGrouping];
// Animate enclosed operations with a duration of 1 second
[[NSAnimationContext currentContext] setDuration:1.0];
[[aView animator] setFrame:newFrame];
...
    [NSAnimationContext beginGrouping];
    // Animate alpha fades with half-second duration
    [[NSAnimationContext currentContext] setDuration:0.5];
    [[aView animator] setAlphaValue:0.75];
    [[bView animator] setAlphaValue:0.75];
    [NSAnimationContext endGrouping];
...
// Will animate with a duration of 1 second
[[bView animator] setFrame:secondFrame];
[NSAnimationContext endGrouping];
```

## Topics

### Grouping Transactions

[`beginGrouping()`](/documentation/AppKit/NSAnimationContext/beginGrouping())

Creates a new animation grouping.

[`endGrouping()`](/documentation/AppKit/NSAnimationContext/endGrouping())

Ends the current animation grouping.

### Getting the Current Animation Context

[`current`](/documentation/AppKit/NSAnimationContext/current)

Returns the current animation context.

### Animation Completion Handlers

[`completionHandler`](/documentation/AppKit/NSAnimationContext/completionHandler)

A completion Block that is called when the animations in the grouping are completed.

[`runAnimationGroup(_:completionHandler:)`](/documentation/AppKit/NSAnimationContext/runAnimationGroup(_:completionHandler:))

Allows you to specify a completion block body after the set of animation actions whose completion will trigger the completion block.

### Modifying the Animation Duration

[`duration`](/documentation/AppKit/NSAnimationContext/duration)

The duration used by animations created as a result of setting new values for an animatable property.

[`timingFunction`](/documentation/AppKit/NSAnimationContext/timingFunction)

The timing function used for all animations within this animation proxy group.

### Implicit Animation

[`allowsImplicitAnimation`](/documentation/AppKit/NSAnimationContext/allowsImplicitAnimation)

Determine if animations are enabled or not for animations that occur as a result of another property change.

### Type Methods

[`runAnimationGroup(_:)`](/documentation/AppKit/NSAnimationContext/runAnimationGroup(_:))



---

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)