---
title: "addFilter(_:options:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/graphicscontext/addfilter(_:options:)"
---

# addFilter(_:options:)

Adds a filter that applies to subsequent drawing operations.

## Declaration

```swift
mutating func addFilter(_ filter: GraphicsContext.Filter, options: GraphicsContext.FilterOptions = FilterOptions())
```

## Parameters

- `filter`: A graphics context filter that you create by calling one of the doc://com.apple.SwiftUI/documentation/SwiftUI/GraphicsContext/Filter factory methods.
- `options`: A set of options from doc://com.apple.SwiftUI/documentation/SwiftUI/GraphicsContext/FilterOptions that you can use to configure filter operations.

## Discussion

Discussion To draw with filtering, SwiftUI: Rasterizes the drawing operation to an implicit transparency layer without blending, adjusting opacity, or applying any clipping. Applies the filter to the layer containing the rasterized image. Composites the layer onto the background, using the context’s current blend mode, opacity setting, and clip shapes. When SwiftUI draws with a filter, the blend mode might apply to regions outside the drawing operation’s intrinsic shape, but inside its clip shape. That might result in unexpected behavior for certain blend modes like copy, where the drawing operation completely overwrites the background even if the source alpha is zero.

## See Also

### Filtering

- [GraphicsContext.Filter](swiftui/graphicscontext/filter.md)
- [GraphicsContext.FilterOptions](swiftui/graphicscontext/filteroptions.md)
- [GraphicsContext.BlurOptions](swiftui/graphicscontext/bluroptions.md)
- [GraphicsContext.ShadowOptions](swiftui/graphicscontext/shadowoptions.md)
