Wednesday, June 12, 2013

CATransaction disableActions example in Objective C (iOS).

CATransaction disableActions

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

+ (BOOL)disableActions

Return Value
YES if actions are disabled.

Discussion of [CATransaction disableActions]
This is a convenience method that returns the boolValue for the valueForKey: value returned by the kCATransactionDisableActions key.

CATransaction disableActions example.
-(void)flagsChanged:(NSEvent *)theEvent
{
    CALayer* layer = self.layer;
    [CATransaction begin];
    CATransaction.disableActions = YES;
    layer.speed = (theEvent.modifierFlags & NSShiftKeyMask) ? 0.1 : 1;
    [CATransaction commit];
}

Example of [CATransaction disableActions].
- (void)carouselDidEndScrollingAnimation:(iCarousel *)carousel {
    BOOL previousDisableActions = [CATransaction disableActions];
    [CATransaction setDisableActions:NO];

    // Begin animation here.

    [CATransaction setDisableActions:previousDisableActions];
}

End of CATransaction disableActions example article.