Declaration
compose().compositingGroup()nonisolated func compositingGroup() -> some ViewReturn value
A view that wraps this view in a compositing group.
Discussion
A compositing group makes compositing effects in this view's ancestor views, such as opacity and the blend mode, take effect before this view is rendered.
Use compositingGroup() to apply effects to a parent view before
applying effects to this view.
In the example below the compositingGroup() modifier separates the
application of effects into stages. It applies the View.opacity(_:)
effect to the VStack before the blur(radius:) effect is applied to the
views inside the enclosed ZStack. This limits the scope of the
opacity change to the outermost view.
VStack {
ZStack {
Text("CompositingGroup")
.foregroundColor(.black)
.padding(20)
.background(Color.red)
Text("CompositingGroup")
.blur(radius: 2)
}
.font(.largeTitle)
.compositingGroup()
.opacity(0.9)
}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.
- 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.
- glassEffectApplies a glass effect to this view.