---
title: "render(in:)"
framework: quartzcore
role: symbol
role_heading: Instance Method
path: "quartzcore/calayer/render(in:)"
---

# render(in:)

Renders the layer and its sublayers into the specified context.

## Declaration

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

## Parameters

- `ctx`: The graphics context to use to render the layer.

## Discussion

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:) to create a UIImage from a CAShapeLayer with a path that describes a circle. After creating the layer, the code creates a CGContext into which the circle is rendered. After rendering, UIGraphicsGetImageFromCurrentImageContext() generates the image. 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 backgroundFilters, filters, compositingFilter, or a mask values. Future versions of macOS may add support for rendering these layers and properties.

## See Also

### Configuring the layer’s rendering behavior

- [isOpaque](quartzcore/calayer/isopaque.md)
- [edgeAntialiasingMask](quartzcore/calayer/edgeantialiasingmask.md)
- [contentsAreFlipped()](quartzcore/calayer/contentsareflipped().md)
- [isGeometryFlipped](quartzcore/calayer/isgeometryflipped.md)
- [drawsAsynchronously](quartzcore/calayer/drawsasynchronously.md)
- [shouldRasterize](quartzcore/calayer/shouldrasterize.md)
- [rasterizationScale](quartzcore/calayer/rasterizationscale.md)
- [contentsFormat](quartzcore/calayer/contentsformat.md)
