---
title: "prepare(_:with:)"
framework: uikit
role: symbol
role_heading: Type Method
path: "uikit/uigraphicsrenderer/prepare(_:with:)"
---

# prepare(_:with:)

Applies the configuration specified in the renderer context to the Core Graphics context.

## Declaration

```swift
class func prepare(_ context: CGContext, with rendererContext: UIGraphicsRendererContext)
```

## Parameters

- `context`: The Core Graphics context that the graphics renderer performs drawing actions on.
- `rendererContext`: The renderer context object that is provided to the doc://com.apple.uikit/documentation/UIKit/UIGraphicsRenderer/runDrawingActions(_:completionActions:) method. This object is of the type returned by the doc://com.apple.uikit/documentation/UIKit/UIGraphicsRenderer/rendererContextClass() static method.

## Discussion

Discussion The graphics renderer calls this method when the runDrawingActions(_:completionActions:) method is invoked. Override this method in a subclass to configure the underlying Core Graphics context before the renderer begins renderering. Core Graphics contexts are reused for repeated calls to the runDrawingActions(_:completionActions:) method. Therefore, be sure to clean up the context to make it ready for reuse.

## See Also

### Managing graphics contexts

- [context(with:)](uikit/uigraphicsrenderer/context(with:).md)
- [rendererContextClass()](uikit/uigraphicsrenderer/renderercontextclass().md)
