<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "QuartzCore",
  "identifier" : "/documentation/QuartzCore/CALayer/backgroundFilters",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Core Animation"
    ],
    "preciseIdentifier" : "c:objc(cs)CALayer(py)backgroundFilters"
  },
  "title" : "backgroundFilters"
}
-->

# backgroundFilters

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

```
var backgroundFilters: [Any]? { get set }
```

## 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 <doc://com.apple.documentation/documentation/CoreImage/CIFilter-swift.class> 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 <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/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:

```swift
let layer = CALayer()
     
if let filter = CIFilter(name:"CIGaussianBlur") {
    filter.name = "myFilter"
    layer.backgroundFilters = [filter]
    layer.setValue(1,
                   forKeyPath: "backgroundFilters.myFilter.inputRadius")
}
```

You use the layer’s [`masksToBounds`](/documentation/QuartzCore/CALayer/masksToBounds) to control the extent of its background filter’s effect.

The following code shows how to create two overlapping text layers, `background` and `foreground`. A Gaussian blur filter is added to the foreground layer’s [`backgroundFilters`](/documentation/QuartzCore/CALayer/backgroundFilters) array and its [`masksToBounds`](/documentation/QuartzCore/CALayer/masksToBounds) is set to <doc://com.apple.documentation/documentation/Swift/true>:

```swift
view.layer = CALayer()
view.layerUsesCoreImageFilters = true
     
let background = CATextLayer()
background.string = "background"
background.backgroundColor = NSColor.red.cgColor
background.alignmentMode = kCAAlignmentCenter
background.fontSize = 96
background.frame = CGRect(x: 10, y: 10, width: 640, height: 160)
     
let foreground = CATextLayer()
foreground.string = "foreground"
foreground.backgroundColor = NSColor.blue.cgColor
foreground.alignmentMode = kCAAlignmentCenter
foreground.fontSize = 48
foreground.opacity = 0.5
foreground.frame = CGRect(x: 20, y: 20, width: 600, height: 60)
foreground.masksToBounds = true
     
if let blurFilter = CIFilter(name: "CIGaussianBlur",
                             withInputParameters: [kCIInputRadiusKey: 2]) {
    foreground.backgroundFilters = [blurFilter]
}
     
view.layer?.addSublayer(background)
background.addSublayer(foreground)
```

The following figure shows the result: the background layer is only blurred where it is overlapped by the foreground layer.

![Background filter effect with mask to bounds](images/com.apple.quartzcore/media-2851423@2x.png)

However, if the foreground layer’s [`masksToBounds`](/documentation/QuartzCore/CALayer/masksToBounds) is set to <doc://com.apple.documentation/documentation/Swift/false>, the entire background layer is blurred as illustrated in the following figure.

![Background filter effect without mask to bounds](images/com.apple.quartzcore/media-2851424@2x.png)

### Special Considerations

This property is not supported on layers in iOS.

---

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)