<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSWindow/setAnchorAttribute(_:for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSWindow(im)setAnchorAttribute:forOrientation:"
  },
  "title" : "setAnchorAttribute(_:for:)"
}
-->

# setAnchorAttribute(_:for:)

Sets the part of the window that stays stationary during constraint-based layout.

```
func setAnchorAttribute(_ attr: NSLayoutConstraint.Attribute, for orientation: NSLayoutConstraint.Orientation)
```

## Parameters

`attr`

The layout attribute. <doc://com.apple.documentation/documentation/UIKit/NSLayoutConstraint/Attribute> specifies the possible values.

`orientation`

The window drag orientation. [`NSLayoutConstraint.Orientation`](/documentation/AppKit/NSLayoutConstraint/Orientation) specifies the possible values.

---

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)