| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/QuartzCore.framework |
| Availability | Available in Mac OS X v10.5 and later. |
| Declared in | CATransaction.h |
| Companion guides | |
| Related sample code |
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 run-loop 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.
Returns the animation duration used by all animations within this transaction group.
+ (CFTimeInterval)animationDuration
An interval of time used as the duration.
This is a convenience method that returns an NSNumber containing the seconds for the valueForKey: value returned by the kCATransactionAnimationDuration key.
CATransaction.hReturns the timing function used for all animations within this transaction group.
+ (CAMediaTimingFunction *)animationTimingFunction
An instance of CAMediaTimingFunction.
This is a convenience method that returns the CAMediaTimingFunction for the valueForKey: value returned by the kCATransactionAnimationTimingFunction key.
CATransaction.hBegin a new transaction for the current thread.
+ (void)begin
The transaction is nested within the thread’s current transaction, if there is one.
CATransaction.hCommit all changes made during the current transaction.
+ (void)commit
Raises an exception if no current transaction exists.
CATransaction.hReturns the completion block object.
+ (void)completionBlock
See setCompletionBlock: for a description of the role of the completion block object.
CATransaction.hReturns whether actions triggered as a result of property changes made within this transaction group are suppressed.
+ (BOOL)disableActions
YES if actions are disabled.
This is a convenience method that returns the boolValue for the valueForKey: value returned by the kCATransactionDisableActions key.
CATransaction.hFlushes any extant implicit transaction.
+ (void)flush
Delays the commit until any nested explicit transactions have completed.
CATransaction.hAttempts to acquire a recursive spin-lock lock, ensuring that returned layer values are valid until unlocked.
+ (void)lock
Core Animation uses a data model that promises not to corrupt the internal data structures when called from multiple threads concurrently, but not that data returned is still valid if the property was valid on another thread. By locking during a transaction you can ensure that data the is read, modified, and set is correctly managed.
CATransaction.hSets the animation duration used by all animations within this transaction group.
+ (void)setAnimationDuration:(CFTimeInterval)duration
An interval of time used as the duration.
This is a convenience method that returns an NSNumber containing the seconds for the valueForKey: value returned by the kCATransactionAnimationDuration key.
CATransaction.hSets the timing function used for all animations within this transaction group.
+ (void)setAnimationTimingFunction:(CAMediaTimingFunction *)function
An instance of CAMediaTimingFunction.
This is a convenience method that returns the CAMediaTimingFunction for the valueForKey: value returned by the kCATransactionAnimationTimingFunction key.
CATransaction.hSets the completion block object.
+ (void)setCompletionBlock:(void (^)(void))block
A block object called when animations for this transaction group are completed.
The block object takes no parameters and returns no value.
The completion block object that is guaranteed to be called (on the main thread) as soon as all animations subsequently added by this transaction group have completed (or have been removed.) If no animations are added before the current transaction group is committed (or the completion block is set to a different value,) the block will be invoked immediately.
CATransaction.hSets whether actions triggered as a result of property changes made within this transaction group are suppressed.
+ (void)setDisableActions:(BOOL)flag
YES, if actions should be disabled.
This is a convenience method that invokes setValue:forKey: with an NSNumber containing a YES for the kCATransactionDisableActions key.
CATransaction.hSets the arbitrary keyed-data for the specified key.
+ (void)setValue:(id)anObject forKey:(NSString *)key
The value for the key identified by key.
The name of one of the receiver's properties.
Nested transactions have nested data scope; setting a key always sets it in the innermost scope.
CATransaction.hRelinquishes a previously acquired transaction lock.
+ (void)unlock
CATransaction.hReturns the arbitrary keyed-data specified by the given key.
+ (id)valueForKey:(NSString *)key
The name of one of the receiver's properties.
The value for the data specified by the key.
Nested transactions have nested data scope. Requesting a value for a key first searches the innermost scope, then the enclosing transactions.
CATransaction.hThese constants define the property keys used by valueForKey: and setValue:forKey:.
NSString * const kCATransactionAnimationDuration; NSString * const kCATransactionDisableActions; NSString * const kCATransactionAnimationTimingFunction; NSString * const kCATransactionCompletionBlock;
kCATransactionAnimationDurationDuration, in seconds, for animations triggered within the transaction group. The value for this key must be an instance of NSNumber.
Available in Mac OS X v10.5 and later.
Declared in CATransaction.h.
kCATransactionDisableActionsIf YES, implicit actions for property changes made within the transaction group are suppressed. The value for this key must be an instance of NSNumber.
Available in Mac OS X v10.5 and later.
Declared in CATransaction.h.
kCATransactionAnimationTimingFunctionAn instance of CAMediaTimingFunction that overrides the timing function for all animations triggered within the transaction group.
Available in Mac OS X v10.6 and later.
Declared in CATransaction.h.
kCATransactionCompletionBlockA completion block object that is guaranteed to be called (on the main thread) as soon as all animations subsequently added by this transaction group have completed (or have been removed.) If no animations are added before the current transaction group is committed (or the completion block is set to a different value,) the block will be invoked immediately.
Available in Mac OS X v10.6 and later.
Declared in CATransaction.h.
CATransaction.h© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-06-01)