<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "QuartzCore",
  "identifier" : "/documentation/QuartzCore/CALayerDelegate/display(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Animation"
    ],
    "preciseIdentifier" : "c:objc(pl)CALayerDelegate(im)displayLayer:"
  },
  "title" : "display(_:)"
}
-->

# display(_:)

Tells the delegate to implement the display process.

```
optional func display(_ layer: CALayer)
```

## Parameters

`layer`

The layer whose contents need updating.

## Discussion

The [`display(_:)`](/documentation/QuartzCore/CALayerDelegate/display(_:)) delegate method is called when the layer is marked for its content to be reloaded, typically initiated by the [`setNeedsDisplay()`](/documentation/QuartzCore/CALayer/setNeedsDisplay()) method. The typical technique for updating is to set the layer’s `contents` property.

The following code shows how you can create a class named `LayerDelegate` that implements [`CALayerDelegate`](/documentation/QuartzCore/CALayerDelegate) and sets it as a layer’s (named `sublayer`) delegate. When [`setNeedsDisplay()`](/documentation/QuartzCore/CALayer/setNeedsDisplay()) is called on `sublayer`, the delegate’s [`display(_:)`](/documentation/QuartzCore/CALayerDelegate/display(_:)) replaces its contents with a specified image.

```swift
let delegate = LayerDelegate()
     
lazy var sublayer: CALayer = {
    let layer = CALayer()
    
    layer.delegate = self.delegate
    
    return layer
}()
     
// When `sublayer.setNeedsDisplay()` is called, `sublayer.contents` are updated.
     
class LayerDelegate: NSObject, CALayerDelegate {
    func display(_ layer: CALayer) {
        layer.contents = UIImage(named: "rabbit.png")?.cgImage
    }
}
```

---

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)