<!--
{
  "availability" : [
    "macOS: 10.11.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSLayoutXAxisAnchor",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSLayoutXAxisAnchor"
  },
  "title" : "NSLayoutXAxisAnchor"
}
-->

# NSLayoutXAxisAnchor

A factory class for creating horizontal layout constraint objects using a fluent API.

```
class NSLayoutXAxisAnchor
```

## Overview

[`NSLayoutXAxisAnchor`](/documentation/AppKit/NSLayoutXAxisAnchor) adds type information to the methods inherited from [`NSLayoutAnchor`](/documentation/AppKit/NSLayoutAnchor). Specifically, the generic methods declared by [`NSLayoutAnchor`](/documentation/AppKit/NSLayoutAnchor) must now take a matching [`NSLayoutXAxisAnchor`](/documentation/AppKit/NSLayoutXAxisAnchor) object.

```objc
// This constraint is valid
[self.cancelButton.leadingAnchor constraintEqualToAnchor:self.saveButton.trailingAnchor  constant: 8.0].active = true;
 
// This constraint generates an incompatible pointer type warning
[self.cancelButton.leadingAnchor constraintEqualToAnchor:self.saveButton.topAnchor constant: 8.0].active = true;
```

For more information on using layout anchors, see [`NSLayoutAnchor`](/documentation/AppKit/NSLayoutAnchor).

## Topics

### Building system spacing constraints

[`-  constraintEqualToSystemSpacingAfterAnchor:multiplier:`](/documentation/AppKit/NSLayoutXAxisAnchor/constraint(equalToSystemSpacingAfter:multiplier:))

Returns a constraint that defines by how much the current anchor trails the specified anchor.

[`-  constraintGreaterThanOrEqualToSystemSpacingAfterAnchor:multiplier:`](/documentation/AppKit/NSLayoutXAxisAnchor/constraint(greaterThanOrEqualToSystemSpacingAfter:multiplier:))

Returns a constraint that defines the minimum amount by which the current anchor trails the specified anchor.

[`-  constraintLessThanOrEqualToSystemSpacingAfterAnchor:multiplier:`](/documentation/AppKit/NSLayoutXAxisAnchor/constraint(lessThanOrEqualToSystemSpacingAfter:multiplier:))

Returns a constraint that defines the maximum amount by which the current anchor trails the specified anchor.

  <doc://com.apple.documentation/documentation/UIKit/creating-self-sizing-table-view-cells>

### Creating a layout dimension

[`-  anchorWithOffsetToAnchor:`](/documentation/AppKit/NSLayoutXAxisAnchor/anchorWithOffset(to:))

Creates a layout dimension object from two anchors.

## See Also

[`NSLayoutConstraint`](/documentation/AppKit/NSLayoutConstraint)

The relationship between two user interface objects that must be satisfied by the constraint-based layout system.

[`NSLayoutYAxisAnchor`](/documentation/AppKit/NSLayoutYAxisAnchor)

A factory class for creating vertical layout constraint objects using a fluent API.

## Relationships

### Conforms To

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Sendable`](/documentation/Swift/Sendable)

[`Equatable`](/documentation/Swift/Equatable)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`Hashable`](/documentation/Swift/Hashable)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

### Inherits From

[`NSLayoutAnchor`](/documentation/AppKit/NSLayoutAnchor)

---

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)