---
title: "setNeedsLayout(_:)"
framework: webkit
role: symbol
role_heading: Instance Method
path: "webkit/webdocumentview/setneedslayout(_:)"
---

# setNeedsLayout(_:)

Sets whether or not the receiver should change its layout.

## Declaration

```swift
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

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 true, it should invoke layout() and reset the internal variable before updating the contents of the view.

## See Also

### Controlling the layout

- [layout()](webkit/webdocumentview/layout().md)
