Skip to content

CALayer: opacity property ​

The opacity property is the layer's opacity, applied to the layer and all its sublayers.

Value ​

A number, a ratio from 0 to 1. 0 is fully transparent; 1 is fully opaque.

Invalid values ​

The written value is converted to a number with Number(). Values that don't convert to a finite number throw TypeError.

Examples ​

js
const layer = new CALayer();
layer.opacity = 0.5;
console.log(layer.opacity);

Result: The console prints 0.5.

Corresponding iOS API ​

CALayer.opacity.

See also ​