<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "QuartzCore",
  "identifier" : "/documentation/QuartzCore/CALayer/render(in:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Animation"
    ],
    "preciseIdentifier" : "c:objc(cs)CALayer(im)renderInContext:"
  },
  "title" : "render(in:)"
}
-->

# render(in:)

Renders the layer and its sublayers into the specified context.

```
func render(in ctx: CGContext)
```

## Parameters

`ctx`

The graphics context to use to render the layer.

## Discussion

This method renders directly from the layer tree, ignoring any animations added to the render tree. Renders in the coordinate space of the layer.

The following code shows how you can use [`render(in:)`](/documentation/QuartzCore/CALayer/render(in:)) to create a <doc://com.apple.documentation/documentation/UIKit/UIImage> from a [`CAShapeLayer`](/documentation/QuartzCore/CAShapeLayer) with a [`path`](/documentation/QuartzCore/CAShapeLayer/path) that describes a circle. After creating the layer, the code creates a <doc://com.apple.documentation/documentation/CoreGraphics/CGContext> into which the circle is rendered. After rendering, <doc://com.apple.documentation/documentation/UIKit/UIGraphicsGetImageFromCurrentImageContext()> generates the image.

```swift
let diameter: CGFloat = 100
let rect = CGRect(origin: CGPoint.zero,
                  size: CGSize(width: diameter, height: diameter))
    
let shapeLayer = CAShapeLayer()
shapeLayer.fillColor = UIColor.white.cgColor
shapeLayer.lineWidth = 10
shapeLayer.path = CGPath(ellipseIn: rect,
                         transform: nil)
        
let renderer = UIGraphicsImageRenderer(size: rect.size)
     
let image = renderer.image {
    context in

    return shapeLayer.render(in: context.cgContext)
}
```

> Important:
> The OS X v10.5 implementation of this method does not support the entire Core Animation composition model. `QCCompositionLayer`, `CAOpenGLLayer`, and `QTMovieLayer` layers are not rendered. Additionally, layers that use 3D transforms are not rendered, nor are layers that specify ``doc://com.apple.quartzcore/documentation/QuartzCore/CALayer/backgroundFilters``, ``doc://com.apple.quartzcore/documentation/QuartzCore/CALayer/filters``, ``doc://com.apple.quartzcore/documentation/QuartzCore/CALayer/compositingFilter``, or a ``doc://com.apple.quartzcore/documentation/QuartzCore/CALayer/mask`` values. Future versions of macOS may add support for rendering these layers and properties.

---

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)