---
title: NSAnimationContext
framework: appkit
role: symbol
role_heading: Class
path: appkit/nsanimationcontext
---

# NSAnimationContext

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

## Declaration

```swift
class NSAnimationContext
```

## Overview

Overview NSAnimationContext is analogous to CATransaction and is similar in overall concept to NSGraphicsContext. Each thread maintains its own stack of nestable NSAnimationContext instances, with each new instance initialized as a copy of the instance below (so, inheriting its current properties). Multiple 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. [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()](appkit/nsanimationcontext/begingrouping().md)
- [endGrouping()](appkit/nsanimationcontext/endgrouping().md)

### Getting the Current Animation Context

- [current](appkit/nsanimationcontext/current.md)

### Animation Completion Handlers

- [completionHandler](appkit/nsanimationcontext/completionhandler.md)
- [runAnimationGroup(_:completionHandler:)](appkit/nsanimationcontext/runanimationgroup(_:completionhandler:).md)

### Modifying the Animation Duration

- [duration](appkit/nsanimationcontext/duration.md)
- [timingFunction](appkit/nsanimationcontext/timingfunction.md)

### Implicit Animation

- [allowsImplicitAnimation](appkit/nsanimationcontext/allowsimplicitanimation.md)

### Type Methods

- [runAnimationGroup(_:)](appkit/nsanimationcontext/runanimationgroup(_:).md)
- [animate(_:changes:completion:)](appkit/nsanimationcontext/animate(_:changes:completion:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### View-Based Animations

- [NSViewAnimation](appkit/nsviewanimation.md)
- [NSAnimatablePropertyContainer](appkit/nsanimatablepropertycontainer.md)
- [NSAnimation.Progress](appkit/nsanimation/progress.md)
- [NSAnimationEffect](appkit/nsanimationeffect.md)
