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 | |
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.h
Returns 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.h
Begin a new transaction for the current thread.
+ (void)begin
The transaction is nested within the thread’s current transaction, if there is one.
CATransaction.h
Commit all changes made during the current transaction.
+ (void)commit
Raises an exception if no current transaction exists.
CATransaction.h
Returns the completion block object.
+ (void)completionBlock
See setCompletionBlock:
for a description of the role of the completion block object.
CATransaction.h
Returns 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.h
Flushes any extant implicit transaction.
+ (void)flush
Delays the commit until any nested explicit transactions have completed.
Flush is typically called automatically at then end of the current runloop, regardless of the runloop mode. If your application does not have a runloop, you must call this method explicitly.
However, you should attempt to avoid calling flush
explicitly. By allowing flush
to execute during the runloop your application will achieve better performance, atomic screen updates will be preserved, and transactions and animations that work from transaction to transaction will continue to function.
CATransaction.h
Attempts 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.h
Sets 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 sets an NSNumber
containing the seconds for the valueForKey:
value of the kCATransactionAnimationDuration
key.
CATransaction.h
Sets 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 sets the CAMediaTimingFunction
for the valueForKey:
value of the kCATransactionAnimationTimingFunction
key.
CATransaction.h
Sets 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.h
Sets 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.h
Sets 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.h
Relinquishes a previously acquired transaction lock.
+ (void)unlock
CATransaction.h
Returns 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.h
These constants define the property keys used by valueForKey:
and setValue:forKey:
.
NSString * const kCATransactionAnimationDuration; NSString * const kCATransactionDisableActions; NSString * const kCATransactionAnimationTimingFunction; NSString * const kCATransactionCompletionBlock;
kCATransactionAnimationDuration
Duration, 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
.
kCATransactionDisableActions
If 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
.
kCATransactionAnimationTimingFunction
An 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
.
kCATransactionCompletionBlock
A 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
Last updated: 2010-01-14