<!--
{
  "availability" : [
    "iOS: 3.0.0 -",
    "iPadOS: 3.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.6.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "QuartzCore",
  "identifier" : "/documentation/QuartzCore/CATransformLayer",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Animation"
    ],
    "preciseIdentifier" : "c:objc(cs)CATransformLayer"
  },
  "title" : "CATransformLayer"
}
-->

# CATransformLayer

Objects used to create true 3D layer hierarchies, rather than the flattened hierarchy rendering model used by other layer types.

```
class CATransformLayer
```

## Overview

Unlike normal layers, transform layers do not flatten their sublayers into the plane at `Z=0`. Due to this, they do not support many of the features of the `CALayer` class compositing model:

- Only the sublayers of a transform layer are rendered. The `CALayer` properties that are rendered by a layer are ignored, including: `backgroundColor`, `contents`, border style properties, stroke style properties, etc.
- The properties that assume 2D image processing are also ignored, including: `filters`, `backgroundFilters`, `compositingFilter`, `mask`, `masksToBounds`, and shadow style properties.
- The `opacity` property is applied to each sublayer individually, the transform layer does not form a compositing group.
- The [`hitTest(_:)`](/documentation/QuartzCore/CALayer/hitTest(_:)) method should never be called on a transform layer as they do not have a 2D coordinate space into which the point can be mapped.

### Example: Displaying layers in 3D

Because [`CATransformLayer`](/documentation/QuartzCore/CATransformLayer) creates true 3D layer hierarchies, you can display otherwise hidden layers when applying 3D transforms.

The following code shows three layers with different colors but identical sizes added at the same position to `layer`. The blue layer is visible because it has the highest [`zPosition`](/documentation/QuartzCore/CALayer/zPosition). Defining the layer’s transform rotates the viewpoint in 3D space and, because `layer` is a [`CATransformLayer`](/documentation/QuartzCore/CATransformLayer), all three layers are visible as illustrated below.

```swift
let layer = CATransformLayer()
     
func layerOfColor(_ color: UIColor, zPosition: CGFloat) -> CALayer {
    let layer = CALayer()
    layer.frame = CGRect(x: 200, y: -200, width: 400, height: 400)
    layer.backgroundColor = color.cgColor
    layer.zPosition = zPosition
    layer.opacity = 0.5
    
    return layer
}
     
layer.addSublayer(layerOfColor(.red, zPosition: 20))
layer.addSublayer(layerOfColor(.green, zPosition: 40))
layer.addSublayer(layerOfColor(.blue, zPosition: 60))
     
var perspective = CATransform3DIdentity
perspective.m34 = -1 / 100
     
layer.transform = CATransform3DRotate(perspective, 0.1, 0, 1, 0)
```

![Hidden layers made visible in 3D with CATransformLayer](images/com.apple.quartzcore/media-2826921@2x.png)

However, if `layer` is created as a [`CALayer`](/documentation/QuartzCore/CALayer), the green and red layers, being hidden by the blue layer, are not rendered as illustrated in the following figure.

![Hidden layers remain hidden in 3D with CALayer](images/com.apple.quartzcore/media-2826922@2x.png)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)