<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.3.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreGraphics",
  "identifier" : "/documentation/CoreGraphics/CGColor/copy(alpha:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Graphics",
      "CoreGraphics"
    ],
    "preciseIdentifier" : "c:@F@CGColorCreateCopyWithAlpha"
  },
  "title" : "copy(alpha:)"
}
-->

# copy(alpha:)

Creates a copy of an existing color, substituting a new alpha value.

```
func copy(alpha: CGFloat) -> CGColor?
```

## Parameters

`alpha`

A value that specifies the desired opacity of the copy. Values outside the range `[0,1]` are clamped to `0` or `1`.

## Return Value

A copy of the specified color, using the specified alpha value. In Objective-C, you’re responsible for releasing this object using [`CGColorRelease`](/documentation/CoreGraphics/CGColorRelease).

## Discussion

---

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)