<!--
{
  "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/fill(_:)-6jc4y",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Graphics",
      "CoreGraphics"
    ],
    "preciseIdentifier" : "s:So12CGContextRefa12CoreGraphicsE4fillyySaySo6CGRectVGF"
  },
  "title" : "fill(_:)"
}
-->

# fill(_:)

Paints the areas contained within the provided rectangles, using the fill color in the current graphics state.

```
func fill(_ rects: [CGRect])
```

## Parameters

`rects`

An array of rectangles, in user space coordinates.

## Discussion

The current path is cleared as a side effect of calling this function.

---

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)