Mac OS X Reference Library Apple Developer
Search

NSAnimationContext Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AppKit.framework
Availability
Available in Mac OS X v10.5 and later.
Declared in
NSAnimationContext.h
Related sample code

Overview

NSAnimationContext is analogous to CATransaction and are 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];

Tasks

Grouping Transactions

Getting the Current Animation Context

Modifying the Animation Duration

Class Methods

beginGrouping

Creates a new animation grouping.

+ (void)beginGrouping

Availability
  • Available in Mac OS X v10.5 and later.
Declared In
NSAnimationContext.h

currentContext

Returns the current animation context.

+ (NSAnimationContext *)currentContext

Return Value

The current animation context.

Availability
  • Available in Mac OS X v10.5 and later.
Declared In
NSAnimationContext.h

endGrouping

Ends the current animation grouping.

+ (void)endGrouping

Availability
  • Available in Mac OS X v10.5 and later.
Declared In
NSAnimationContext.h

Instance Methods

duration

Returns the duration used when animating object properties that support animation.

- (NSTimeInterval)duration

Return Value

The duration in seconds.

Availability
  • Available in Mac OS X v10.5 and later.
Declared In
NSAnimationContext.h

setDuration:

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

- (void)setDuration:(NSTimeInterval)duration

Parameters
duration

The duration in seconds.

Discussion

Any animations that occur as a result of setting the values of animatable properties in the current context will run for this duration.

Availability
  • Available in Mac OS X v10.5 and later.
Declared In
NSAnimationContext.h



Last updated: 2008-02-08

Did this document help you? Yes It's good, but... Not helpful...