<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: -",
    "macOS: 10.9.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreGraphics",
  "identifier" : "/documentation/CoreGraphics/CGContext/draw(_:in:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Graphics",
      "CoreGraphics"
    ],
    "preciseIdentifier" : "s:So12CGContextRefa12CoreGraphicsE4draw_2inySo07CGLayerB0a_So6CGRectVtF"
  },
  "title" : "draw(_:in:)"
}
-->

# draw(_:in:)

Draws the contents of a layer object into the specified rectangle.

```
func draw(_ layer: CGLayer, in rect: CGRect)
```

## Parameters

`layer`

The layer whose contents you want to draw.

`rect`

The rectangle, in current user space coordinates, to draw in.

## Discussion

The contents are scaled, if necessary, to fit into the rectangle.

---

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)