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

# setStrokeColor(_:)

Sets the current stroke color.

```
func setStrokeColor(_ 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 stroke color space, plus an additional component for the alpha value.

## Discussion

The current stroke color space must not be a pattern color space. For information on setting the stroke color when using a pattern color space, see [`setStrokePattern(_:colorComponents:)`](/documentation/CoreGraphics/CGContext/setStrokePattern(_:colorComponents:)). 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)