<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.0.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreGraphics",
  "identifier" : "/documentation/CoreGraphics/CGContext/fill(_:)-7a0rk",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Graphics",
      "CoreGraphics"
    ],
    "preciseIdentifier" : "c:@F@CGContextFillRect"
  },
  "title" : "fill(_:)"
}
-->

# fill(_:)

Paints the area contained within the provided rectangle, using the fill color in the current graphics state.

```
func fill(_ rect: CGRect)
```

## Parameters

`rect`

A rectangle, in user space coordinates.

## Discussion

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

## See Also

[`CGContextFillRects`](/documentation/CoreGraphics/CGContextFillRects)

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



---

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)