Instance Property

backgroundFilters

An array of Core Image filters to apply to the content immediately behind the layer. Animatable.

Declaration

@property(copy) NSArray *backgroundFilters;

Discussion

Background filters affect the content behind the layer that shows through into the layer itself. Typically this content belongs to the superlayer that acts as the parent of the layer. These filters do not affect the content of the layer itself, including the layer’s background color and border.

The default value of this property is nil.

Changing the inputs of the CIFilter object directly after it is attached to the layer causes undefined behavior. In macOS, it is possible to modify filter parameters after attaching them to the layer but you must use the layer’s setValue:forKeyPath: method to do so. In addition, you must assign a name to the filter so that you can identify it in the array. For example, to change the inputRadius parameter of the filter, you could use code similar to the following:

CIFilter *filter = ...;
CALayer *layer = ...;
 
filter.name = @"myFilter";
layer.backgroundFilters = [NSArray arrayWithObject:filter];
[layer setValue:[NSNumber numberWithInt:1] forKeyPath:@"backgroundFilters.myFilter.inputRadius"];

You use the layer's masksToBounds to control the extent of its background filter's effect.

Special Considerations

This property is not supported on layers in iOS.

See Also

Layer Filters

filters

An array of Core Image filters to apply to the contents of the layer and its sublayers. Animatable.

compositingFilter

A CoreImage filter used to composite the layer and the content behind it. Animatable.

minificationFilter

The filter used when reducing the size of the content.

minificationFilterBias

The bias factor used by the minification filter to determine the levels of detail.

magnificationFilter

The filter used when increasing the size of the content.