<!--
{
  "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/setFillColor(_:)-756dy",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Graphics",
      "CoreGraphics"
    ],
    "preciseIdentifier" : "c:@F@CGContextSetFillColor"
  },
  "title" : "setFillColor(_:)"
}
-->

# setFillColor(_:)

Sets the current fill color.

```
func setFillColor(_ components: UnsafePointer<CGFloat>)
```

## Parameters

`components`

An array of intensity values describing the color to set. The number of array elements must equal the number of components in the current fill color space, plus an additional component for the alpha value.

## Discussion

The current fill color space must not be a pattern color space. For information on setting the fill color when using a pattern color space, see [`setFillPattern(_:colorComponents:)`](/documentation/CoreGraphics/CGContext/setFillPattern(_:colorComponents:)). Note that the preferred API to use is now [`setFillColor(_:)`](/documentation/CoreGraphics/CGContext/setFillColor(_:)-8lhn8).

---

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)