<!--
{
  "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:byTiling:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Graphics",
      "CoreGraphics"
    ],
    "preciseIdentifier" : "s:So12CGContextRefa12CoreGraphicsE4draw_2in8byTilingySo07CGImageB0a_So6CGRectVSbtF"
  },
  "title" : "draw(_:in:byTiling:)"
}
-->

# draw(_:in:byTiling:)

Draws an image in the specified area.

```
func draw(_ image: CGImage, in rect: CGRect, byTiling: Bool = false)
```

## Parameters

`image`

The image to draw.

`rect`

The rectangle, in user space coordinates, in which to draw the image.

`byTiling`

If <doc://com.apple.documentation/documentation/Swift/true>, this method fills the context’s entire clipping region by tiling many copies of the image, and the `rect` parameter defines the origin and size of the tiling pattern.

    If     <doc://com.apple.documentation/documentation/Swift/false>     (the default), this method draws a single copy of the image in the area defined by the     `rect`     parameter.

## Discussion

This method scales the image (disproportionately, if necessary) to fit the bounds specified by the `rect` parameter.When the `byTiling` parameter is <doc://com.apple.documentation/documentation/Swift/true>, the image is tiled in user space—thus, unlike when drawing with patterns, the current transformation (see the [`ctm`](/documentation/CoreGraphics/CGContext/ctm) property) affects the final result.

---

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)