---
title: "setOpacityRamp(fromStartOpacity:toEndOpacity:timeRange:)"
framework: avfoundation
role: symbol
role_heading: Instance Method
path: "avfoundation/avmutablevideocompositionlayerinstruction/setopacityramp(fromstartopacity:toendopacity:timerange:)"
---

# setOpacityRamp(fromStartOpacity:toEndOpacity:timeRange:)

Sets an opacity ramp to apply during a specified time range.

## Declaration

```swift
func setOpacityRamp(fromStartOpacity startOpacity: Float, toEndOpacity endOpacity: Float, timeRange: CMTimeRange)
```

## Parameters

- `startOpacity`: The opacity to be applied at the start time of timeRange. The value must be between 0.0 and 1.0.
- `endOpacity`: The opacity to be applied at the end time of timeRange. The value must be between 0.0 and 1.0.
- `timeRange`: The time range over which the value of the opacity is interpolated between startOpacity and endOpacity.

## Discussion

Discussion During an opacity ramp, opacity is computed using a linear interpolation. 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

- [setOpacity(_:at:)](avfoundation/avmutablevideocompositionlayerinstruction/setopacity(_:at:).md)
- [setTransform(_:at:)](avfoundation/avmutablevideocompositionlayerinstruction/settransform(_:at:).md)
- [setTransformRamp(fromStart:toEnd:timeRange:)](avfoundation/avmutablevideocompositionlayerinstruction/settransformramp(fromstart:toend:timerange:).md)
