---
title: "copy(alpha:)"
framework: coregraphics
role: symbol
role_heading: Instance Method
path: "coregraphics/cgcolor/copy(alpha:)"
---

# copy(alpha:)

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

## Declaration

```swift
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

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.

## See Also

### Creating Colors

- [copy()](coregraphics/cgcolor/copy().md)
- [init(genericCMYKCyan:magenta:yellow:black:alpha:)](coregraphics/cgcolor/init(genericcmykcyan:magenta:yellow:black:alpha:).md)
- [init(gray:alpha:)](coregraphics/cgcolor/init(gray:alpha:).md)
- [init(genericGrayGamma2_2Gray:alpha:)](coregraphics/cgcolor/init(genericgraygamma2_2gray:alpha:).md)
- [init(red:green:blue:alpha:)](coregraphics/cgcolor/init(red:green:blue:alpha:).md)
- [init(srgbRed:green:blue:alpha:)](coregraphics/cgcolor/init(srgbred:green:blue:alpha:).md)
- [init(colorSpace:components:)](coregraphics/cgcolor/init(colorspace:components:).md)
- [init(patternSpace:pattern:components:)](coregraphics/cgcolor/init(patternspace:pattern:components:).md)
