<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIGraphicsRenderer/prepare(_:with:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIGraphicsRenderer(cm)prepareCGContext:withRendererContext:"
  },
  "title" : "prepare(_:with:)"
}
-->

# prepare(_:with:)

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

```
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 [`runDrawingActions(_:completionActions:)`](/documentation/UIKit/UIGraphicsRenderer/runDrawingActions(_:completionActions:)) method. This object is of the type returned by the [`rendererContextClass()`](/documentation/UIKit/UIGraphicsRenderer/rendererContextClass()) static method.

## Discussion

The graphics renderer calls this method when the [`runDrawingActions(_:completionActions:)`](/documentation/UIKit/UIGraphicsRenderer/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:)`](/documentation/UIKit/UIGraphicsRenderer/runDrawingActions(_:completionActions:)) method. Therefore, be sure to clean up the context to make it ready for reuse.

---

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)