<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/GraphicsContext/addFilter(_:options:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI15GraphicsContextV9addFilter_7optionsyAC0F0V_AC0F7OptionsVtF"
  },
  "title" : "addFilter(_:options:)"
}
-->

# addFilter(_:options:)

Adds a filter that applies to subsequent drawing operations.

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

## Parameters

`filter`

A graphics context filter that you create by calling one
of the [`GraphicsContext.Filter`](/documentation/SwiftUI/GraphicsContext/Filter) factory methods.

`options`

A set of options from [`GraphicsContext.FilterOptions`](/documentation/SwiftUI/GraphicsContext/FilterOptions) that you can use to
configure filter operations.

## 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`](/documentation/SwiftUI/GraphicsContext/BlendMode-swift.struct/copy), where
the drawing operation completely overwrites the background even if
the source alpha is zero.

---

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)