CATransaction kCATransactionDisableActions
These constants define the property keys used by valueForKey: and setValue:forKey:.
NSString * const kCATransactionAnimationDuration;
NSString * const kCATransactionDisableActions;
NSString * const kCATransactionAnimationTimingFunction;
NSString * const kCATransactionCompletionBlock;
Constants
kCATransactionAnimationDuration
Duration, in seconds, for animations triggered within the transaction group. The value for this key must be an instance of NSNumber.
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.
kCATransactionAnimationTimingFunction
An instance of CAMediaTimingFunction that overrides the timing function for all animations triggered within the transaction group.
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.
CATransaction kCATransactionDisableActions example.
- (void)popViewControllerMoveInFromTop {
[CATransaction begin];
CATransition *transition;
transition = [CATransition animation];
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromTop;
transition.duration = 0.7;
[CATransaction setValue:(id)kCFBooleanTrue
forKey:kCATransactionDisableActions];
[self.view.layer addAnimation:transition forKey:nil];
[self popViewControllerAnimated:NO];
[CATransaction commit];
}
[CATransaction begin];
CATransition *transition;
transition = [CATransition animation];
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromTop;
transition.duration = 0.7;
[CATransaction setValue:(id)kCFBooleanTrue
forKey:kCATransactionDisableActions];
[self.view.layer addAnimation:transition forKey:nil];
[self popViewControllerAnimated:NO];
[CATransaction commit];
}
Example of [CATransaction kCATransactionDisableActions].
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue
forKey:kCATransactionDisableActions];
layer.content = someImageRef;
[CATransaction commit];
[CATransaction setValue:(id)kCFBooleanTrue
forKey:kCATransactionDisableActions];
layer.content = someImageRef;
[CATransaction commit];
CATransaction kCATransactionDisableActions example.
You can temporarily disable layer actions when changing layer property values by setting the value of the transaction’s kCATransactionDisableActions to true. Any changes made during the scope of that transaction will not result in an animation occurring. Listing 2 shows an example that disables the fade animation that occurs when removing aLayer from a visible layer-tree.
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue
forKey:kCATransactionDisableActions];
[aLayer removeFromSuperlayer];
[CATransaction commit];
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue
forKey:kCATransactionDisableActions];
[aLayer removeFromSuperlayer];
[CATransaction commit];