Class

CATransaction

A mechanism for grouping multiple layer-tree operations into atomic updates to the render tree.

Declaration

@interface CATransaction : NSObject

Overview

CATransaction is the Core Animation mechanism for batching multiple layer-tree operations into atomic updates to the render tree. Every modification to a layer tree must be part of a transaction. Nested transactions are supported.

Core Animation supports two types of transactions: implicit transactions and explicit transactions. Implicit transactions are created automatically when the layer tree is modified by a thread without an active transaction and are committed automatically when the thread's runloop next iterates. Explicit transactions occur when the the application sends the CATransaction class a begin message before modifying the layer tree, and a commit message afterwards.

CATransaction allows you to override default animation properties that are set for animatable properties. You can customize duration, timing function, whether changes to properties trigger animations, and provide a handler that informs you when all animations from the transaction group are completed.

During a transaction you can temporarily acquire a recursive spin lock for managing property atomicity.

Topics

Creating and Committing Transactions

+ begin

Begin a new transaction for the current thread.

+ commit

Commit all changes made during the current transaction.

+ flush

Flushes any extant implicit transaction.

Overriding Animation Duration and Timing

+ animationDuration

Returns the animation duration used by all animations within this transaction group.

+ setAnimationDuration:

Sets the animation duration used by all animations within this transaction group.

+ animationTimingFunction

Returns the timing function used for all animations within this transaction group.

+ setAnimationTimingFunction:

Sets the timing function used for all animations within this transaction group.

Temporarily Disabling Property Animations

+ disableActions

Returns whether actions triggered as a result of property changes made within this transaction group are suppressed.

+ setDisableActions:

Sets whether actions triggered as a result of property changes made within this transaction group are suppressed.

Getting and Setting Completion Block Objects

+ completionBlock

Returns the completion block object.

+ setCompletionBlock:

Sets the completion block object.

Managing Concurrency

+ lock

Attempts to acquire a recursive spin-lock lock, ensuring that returned layer values are valid until unlocked.

+ unlock

Relinquishes a previously acquired transaction lock.

Getting and Setting Transaction Properties

+ setValue:forKey:

Sets the arbitrary keyed-data for the specified key.

+ valueForKey:

Returns the arbitrary keyed-data specified by the given key.

Constants

Transaction properties

These constants define the property keys used by valueForKey: and setValue:forKey:.

Relationships

Inherits From

See Also

Animation Groups

CAAnimationGroup

An object that allows multiple animations to be grouped and run concurrently.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software