Declaration
compose().drawingGroup({
opaque?: boolean,
colorMode?: SwiftUI.ColorRenderingMode,
})nonisolated func drawingGroup(
opaque: Bool = false,
colorMode: ColorRenderingMode = .nonLinear
) -> some ViewParameters
options.opaquebooleanA Boolean value that indicates whether the image is opaque. The default is
false; if set totrue, the alpha channel of the image must be1.options.colorModeSwiftUI.ColorRenderingModeOne of the working color space and storage formats defined in
ColorRenderingMode. The default isColorRenderingMode.nonLinear.
Return value
A view that composites this view's contents into an offscreen image before display.
Discussion
The drawingGroup(opaque:colorMode:) modifier flattens a subtree of
views into a single view before rendering it.
In the example below, the contents of the view are composited to a single bitmap; the bitmap is then displayed in place of the view:
VStack {
ZStack {
Text("DrawingGroup")
.foregroundColor(.black)
.padding(20)
.background(Color.red)
Text("DrawingGroup")
.blur(radius: 2)
}
.font(.largeTitle)
.compositingGroup()
.opacity(1.0)
}
.background(Color.white)
.drawingGroup()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.
- glassEffectApplies a glass effect to this view.