<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/drawingGroup(opaque:colorMode:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE12drawingGroup6opaque9colorModeQrSb_AA014ColorRenderingH0OtF"
  },
  "title" : "drawingGroup(opaque:colorMode:)"
}
-->

# drawingGroup(opaque:colorMode:)

Composites this view’s contents into an offscreen image before final
display.

```
nonisolated func drawingGroup(opaque: Bool = false, colorMode: ColorRenderingMode = .nonLinear) -> some View
```

## Parameters

`opaque`

A Boolean value that indicates whether the image is opaque.
The default is `false`; if set to `true`, the alpha channel of the
image must be `1`.

`colorMode`

One of the working color space and storage formats
defined in [`ColorRenderingMode`](/documentation/SwiftUI/ColorRenderingMode). The default is
[`ColorRenderingMode.nonLinear`](/documentation/SwiftUI/ColorRenderingMode/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()
```

> Important: The visual result of a drawing group only includes views
> that SwiftUI rasterizes directly using its own drawing primitives,
> such as text, images, shapes, and composite views of these types.
> It will not include views whose contents are composited by Core
> Animation layers, such as more complex controls and containers, web
> views, media players, and most types of UIKit and AppKit views. In
> those cases, the output displays a placeholder image instead.
> Whether a particular view is rendered using SwiftUI’s own drawing
> primitives or composited by Core Animation may change in future
> releases. However, any view that is currently supported is
> guaranteed to remain supported.

![A screenshot showing the effects on several stacks configured as a](images/com.apple.SwiftUI/SwiftUI-View-drawingGroup@2x.png)

---

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)