<!--
{
  "availability" : [
    "macOS: 10.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSView/wantsLayer",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSView(py)wantsLayer"
  },
  "title" : "wantsLayer"
}
-->

# wantsLayer

A Boolean value indicating whether the view uses a layer as its backing store.

```
var wantsLayer: Bool { get set }
```

## Discussion

Setting the value of this property to <doc://com.apple.documentation/documentation/Swift/true> turns the view into a layer-backed view—that is, the view uses a <doc://com.apple.documentation/documentation/QuartzCore/CALayer> object to manage its rendered content. Creating a layer-backed view implicitly causes the entire view hierarchy under that view to become layer-backed. Thus, the view and all of its subviews (including subviews of subviews) become layer-backed. The default value of this property is <doc://com.apple.documentation/documentation/Swift/false>.

In a layer-backed view, any drawing done by the view is cached to the underlying layer object. This cached content can then be manipulated in ways that are more performant than redrawing the view contents explicitly. AppKit automatically creates the underlying layer object (using the [`makeBackingLayer()`](/documentation/AppKit/NSView/makeBackingLayer()) method) and handles the caching of the view’s content. If the [`wantsUpdateLayer`](/documentation/AppKit/NSView/wantsUpdateLayer) method returns <doc://com.apple.documentation/documentation/Swift/false>, you should not interact with the underlying layer object directly. Instead, use the methods of this class to make any changes to the view and its layer. If [`wantsUpdateLayer`](/documentation/AppKit/NSView/wantsUpdateLayer) returns <doc://com.apple.documentation/documentation/Swift/true>, it is acceptable (and appropriate) to modify the layer in the view’s [`updateLayer()`](/documentation/AppKit/NSView/updateLayer()) method.

For layer-backed views, you can flatten the layer hierarchy by setting the [`canDrawSubviewsIntoLayer`](/documentation/AppKit/NSView/canDrawSubviewsIntoLayer) property to <doc://com.apple.documentation/documentation/Swift/true>. To prevent a subview from having its contents flattened into this view’s layer, explicitly set the value of the subview’s [`wantsLayer`](/documentation/AppKit/NSView/wantsLayer) property to <doc://com.apple.documentation/documentation/Swift/true>.

In addition to creating a layer-backed view, you can create a layer-hosting view by assigning a layer directly to the view’s [`layer`](/documentation/AppKit/NSView/layer) property. In a layer-hosting view, you are responsible for managing the view’s layer. To create a layer-hosting view, you must set the [`layer`](/documentation/AppKit/NSView/layer) property first and then set this property to <doc://com.apple.documentation/documentation/Swift/true>. The order in which you set the values of these properties is crucial.

In a layer-hosting view, do not rely on the view for drawing. Similarly, do not add subviews to a layer-hosting view. The root layer—that is, the layer you set using the [`layer`](/documentation/AppKit/NSView/layer) property—becomes the root layer of the layer tree. Any manipulations of that layer tree must be done using the Core Animation interfaces. You still use the view for handling mouse and keyboard events, but drawing must be handled by Core Animation.

---

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)