<!--
{
  "availability" : [
    "macOS: 10.3.0 - 10.14.0"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WebDocumentView/setNeedsLayout(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(pl)WebDocumentView(im)setNeedsLayout:"
  },
  "title" : "setNeedsLayout(_:)"
}
-->

# setNeedsLayout(_:)

Sets whether or not the receiver should change its layout.

```
func setNeedsLayout(_ flag: Bool)
```

## Parameters

`flag`

Sets whether the receiver needs to update its layout in the next call to its <doc://com.apple.documentation/documentation/AppKit/NSView/draw(_:)> method.

## Discussion

A view conforming to this protocol should store the most recent value of this flag in an internal variable. Then, in its drawRect method, if the most recent value of this flag was <doc://com.apple.documentation/documentation/Swift/true>, it should invoke [`layout()`](/documentation/WebKit/WebDocumentView/layout()) and reset the internal variable before updating the contents of the view.

---

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)