---
title: "setOpacity(_:at:)"
framework: avfoundation
role: symbol
role_heading: Instance Method
path: "avfoundation/avmutablevideocompositionlayerinstruction/setopacity(_:at:)"
---

# setOpacity(_:at:)

Sets the opacity value at a specific time within the time range of the instruction.

## Declaration

```swift
func setOpacity(_ opacity: Float, at time: CMTime)
```

## Parameters

- `opacity`: The opacity to be applied at time. The value must be between 0.0 and 1.0.
- `time`: A time value within the time range of the composition instruction.

## Discussion

Discussion Sets a fixed opacity to apply from the specified time until the next time at which an opacity is set; this is the same as setting a flat ramp for that time range. Before the first time for which an opacity is set, the opacity is held constant at 1.0; after the last specified time, the opacity is held constant at the last value.

## See Also

### Managing properties

- [setOpacityRamp(fromStartOpacity:toEndOpacity:timeRange:)](avfoundation/avmutablevideocompositionlayerinstruction/setopacityramp(fromstartopacity:toendopacity:timerange:).md)
- [setTransform(_:at:)](avfoundation/avmutablevideocompositionlayerinstruction/settransform(_:at:).md)
- [setTransformRamp(fromStart:toEnd:timeRange:)](avfoundation/avmutablevideocompositionlayerinstruction/settransformramp(fromstart:toend:timerange:).md)
