<!--
{
  "availability" : [
    "iOS: 4.0.0 - 26.0.0",
    "iPadOS: 4.0.0 - 26.0.0",
    "macCatalyst: 13.1.0 - 26.0.0",
    "macOS: 10.7.0 - 26.0.0",
    "tvOS: 9.0.0 - 26.0.0",
    "visionOS: 1.0.0 - 26.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVMutableVideoCompositionLayerInstruction/setOpacityRamp(fromStartOpacity:toEndOpacity:timeRange:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVMutableVideoCompositionLayerInstruction(im)setOpacityRampFromStartOpacity:toEndOpacity:timeRange:"
  },
  "title" : "setOpacityRamp(fromStartOpacity:toEndOpacity:timeRange:)"
}
-->

# setOpacityRamp(fromStartOpacity:toEndOpacity:timeRange:)

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

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

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.

---

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)