visualEffect
Applies effects to this view, while providing access to layout information through a geometry proxy.
Declaration
compose().visualEffect(
effect: (effect: SymbolicEffect, arg1: SymbolicValue) => SymbolicEffect
)nonisolated func visualEffect(
_ effect: @escaping @Sendable (EmptyVisualEffect, GeometryProxy) -> some VisualEffect
) -> some ViewParameters
effect*(effect: SymbolicEffect, arg1: SymbolicValue) => SymbolicEffectA closure that returns the effect to be applied. The first argument provided to the closure is a placeholder representing this view. The second argument is a
GeometryProxy.
Return value
A view with the effect applied.
Discussion
You return new effects by calling functions on the first argument
provided to the effect closure. In this example, ContentView is
offset by its own size, causing its top left corner to appear where the
bottom right corner was originally located:
ContentView()
.visualEffect { content, geometryProxy in
content.offset(geometryProxy.size)
}See also
More in Visual effects.
- allowedDynamicRangeReturns a new view configured with the specified allowed dynamic range.
- backgroundExtensionEffectAdds the background extension effect to the view. The view will be duplicated into mirrored copies which will be placed around the view on any edge with available safe area. Additionally, a blur effect will be applied on top to blur out the copies.
- blurApplies a Gaussian blur to this view.
- brightnessBrightens this view by the specified amount.
- clippedClips this view to its bounding rectangular frame.
- colorEffectReturns a new view that applies shader to self as a filter effect on the color of each pixel.
- colorInvertInverts the colors in this view.
- colorMultiplyAdds a color multiplication effect to this view.
- compositingGroupWraps this view in a compositing group.
- contrastSets the contrast and separation between similar colors in this view.
- distortionEffectReturns a new view that applies shader to self as a geometric distortion effect on the location of each pixel.
- drawingGroupComposites this view's contents into an offscreen image before final display.