<!--
{
  "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/CAReplicatorLayer",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Animation"
    ],
    "preciseIdentifier" : "c:objc(cs)CAReplicatorLayer"
  },
  "title" : "CAReplicatorLayer"
}
-->

# CAReplicatorLayer

A layer that creates a specified number of sublayer copies with varying geometric, temporal, and color transformations.

```
class CAReplicatorLayer
```

## Overview

You can use a [`CAReplicatorLayer`](/documentation/QuartzCore/CAReplicatorLayer) object to build complex layouts based on a single source layer that is replicated with transformation rules that can affect the position, rotation color, and time.

The following shows a simple example: a red square is added to a replicator layer with an instance count of `5`. The position of each replicated instance is offset along the `x` axis so that it appears to the right of the previous instance. The blue and green color channels are offset so that their values reach `0` at the final instance.

```swift
let replicatorLayer = CAReplicatorLayer()
     
let redSquare = CALayer()
redSquare.backgroundColor = NSColor.white.cgColor
redSquare.frame = CGRect(x: 0, y: 0, width: 100, height: 100)
     
let instanceCount = 5
     
replicatorLayer.instanceCount = instanceCount
replicatorLayer.instanceTransform = CATransform3DMakeTranslation(110, 0, 0)
     
let offsetStep = -1 / Float(instanceCount)
replicatorLayer.instanceBlueOffset = offsetStep
replicatorLayer.instanceGreenOffset = offsetStep
    
replicatorLayer.addSublayer(redSquare)
```

The result of the code above is a row of five squares, with colors graduating from white to red.

![Replicator layer example](images/com.apple.quartzcore/media-2776906@2x.png)

Replicator layers can be nested. The following code adds `replicatorLayer` to a second replicator layer that offsets the position of each instance vertically and subtracts from the red channel.

```swift
let outerReplicatorLayer = CAReplicatorLayer()

outerReplicatorLayer.addSublayer(replicatorLayer)

outerReplicatorLayer.instanceCount = instanceCount
outerReplicatorLayer.instanceTransform = CATransform3DMakeTranslation(0, 110, 0)
outerReplicatorLayer.instanceRedOffset = offsetStep
```

The result of adding this code is to create a grid with the value of the red channel being reduced in the vertical direction.

![Nested replicator layer example](images/com.apple.quartzcore/media-2776908@2x.png)

> Note:
> The ``doc://com.apple.quartzcore/documentation/QuartzCore/CAReplicatorLayer`` implementation of ``doc://com.apple.quartzcore/documentation/QuartzCore/CALayer/hitTest(_:)`` currently tests only the first instance of z replicator layer’s sublayers. This may change in the future.

## Topics

### Setting Instance Display Properties

[`instanceCount`](/documentation/QuartzCore/CAReplicatorLayer/instanceCount)

The number of copies to create, including the source layers.

[`instanceDelay`](/documentation/QuartzCore/CAReplicatorLayer/instanceDelay)

Specifies the delay, in seconds, between replicated copies. Animatable.

[`instanceTransform`](/documentation/QuartzCore/CAReplicatorLayer/instanceTransform)

The transform matrix applied to the previous instance to produce the current instance. Animatable.

### Modifying Instance Layer Geometry

[`preservesDepth`](/documentation/QuartzCore/CAReplicatorLayer/preservesDepth)

Defines whether this layer flattens its sublayers into its plane.

### Accessing Instance Color Values

[`instanceColor`](/documentation/QuartzCore/CAReplicatorLayer/instanceColor)

Defines the color used to multiply the source object. Animatable.

[`instanceRedOffset`](/documentation/QuartzCore/CAReplicatorLayer/instanceRedOffset)

Defines the offset added to the red component of the color for each replicated instance. Animatable.

[`instanceGreenOffset`](/documentation/QuartzCore/CAReplicatorLayer/instanceGreenOffset)

Defines the offset added to the green component of the color for each replicated instance. Animatable.

[`instanceBlueOffset`](/documentation/QuartzCore/CAReplicatorLayer/instanceBlueOffset)

Defines the offset added to the blue component of the color for each replicated instance. Animatable.

[`instanceAlphaOffset`](/documentation/QuartzCore/CAReplicatorLayer/instanceAlphaOffset)

Defines the offset added to the alpha component of the color for each replicated instance. Animatable.



---

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)