NSAnimationContext
An animation context, which contains information about environment and state.
Declaration
class NSAnimationContextOverview
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];