---
title: CATransaction
framework: quartzcore
role: symbol
role_heading: Class
path: quartzcore/catransaction
---

# CATransaction

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

## Declaration

```swift
class CATransaction
```

## Overview

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. CATransaction supports nested transactions. The following code shows how you can fade out a layer (named transitioningLayer) over a 2 second duration while scaling it to three times its original size. The scale animation is within a nested transaction with its own duration of 1 second. After the outer transaction completes, a completion block removes transitioningLayer from its parent layer. let transitioningLayer = CALayer()       // Outer transaction animates `opacity` to 0 over 2 seconds CATransaction.begin() CATransaction.setAnimationDuration(2) CATransaction.setCompletionBlock {     transitioningLayer.removeFromSuperlayer() }      transitioningLayer.opacity = 0       // Inner transaction animates scale to (3, 3, 3) over 1 second CATransaction.begin() CATransaction.setAnimationDuration(1)       transitioningLayer.transform = CATransform3DMakeScale(3, 3, 3)       CATransaction.commit() // Commits inner transaction CATransaction.commit() // Commits outer transaction

## Topics

### Creating and Committing Transactions

- [begin()](quartzcore/catransaction/begin().md)
- [commit()](quartzcore/catransaction/commit().md)
- [flush()](quartzcore/catransaction/flush().md)

### Overriding Animation Duration and Timing

- [animationDuration()](quartzcore/catransaction/animationduration().md)
- [setAnimationDuration(_:)](quartzcore/catransaction/setanimationduration(_:).md)
- [animationTimingFunction()](quartzcore/catransaction/animationtimingfunction().md)
- [setAnimationTimingFunction(_:)](quartzcore/catransaction/setanimationtimingfunction(_:).md)

### Temporarily Disabling Property Animations

- [disableActions()](quartzcore/catransaction/disableactions().md)
- [setDisableActions(_:)](quartzcore/catransaction/setdisableactions(_:).md)

### Getting and Setting Completion Block Objects

- [completionBlock()](quartzcore/catransaction/completionblock().md)
- [setCompletionBlock(_:)](quartzcore/catransaction/setcompletionblock(_:).md)

### Managing Concurrency

- [lock()](quartzcore/catransaction/lock().md)
- [unlock()](quartzcore/catransaction/unlock().md)

### Getting and Setting Transaction Properties

- [setValue(_:forKey:)](quartzcore/catransaction/setvalue(_:forkey:).md)
- [value(forKey:)](quartzcore/catransaction/value(forkey:).md)

### Constants

- [Transaction properties](quartzcore/transaction-properties.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Animation Groups

- [CAAnimationGroup](quartzcore/caanimationgroup.md)
