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

# setStrokeColorSpace(_:)

Sets the stroke color space in a graphics context.

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

## Parameters

`space`

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

## Discussion

As a side effect when you call this function, Core Graphics assigns an appropriate initial value to the stroke color, based on the color space you specify. To change this value, call [`setStrokeColor(_:)`](/documentation/CoreGraphics/CGContext/setStrokeColor(_:)-4pd8p). Note that the preferred API is now [`setStrokeColor(_:)`](/documentation/CoreGraphics/CGContext/setStrokeColor(_:)-1sskg).

---

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)