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

# setFillColorSpace(_:)

Sets the fill color space in a graphics context.

```
func setFillColorSpace(_ space: CGColorSpace)
```

## Parameters

`space`

The new fill color space. The color space is retained; upon return, you may safely release it.

## Discussion

As a side effect of this function, Core Graphics assigns an appropriate initial value to the fill color, based on the specified color space. To change this value, call [`setFillColor(_:)`](/documentation/CoreGraphics/CGContext/setFillColor(_:)-756dy). 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)