<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/NSLayoutDimension",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSLayoutDimension"
  },
  "title" : "NSLayoutDimension"
}
-->

# NSLayoutDimension

A factory class for creating size-based layout constraint objects using a fluent API.

```
@MainActor class NSLayoutDimension
```

## Overview

Use these constraints to programmatically define your layout using Auto Layout. All sizes are measured in points. In addition to providing size-specific methods for creating constraints, this class adds type information to the methods inherited from [`NSLayoutAnchor`](/documentation/UIKit/NSLayoutAnchor). Specifically, the generic methods declared by [`NSLayoutAnchor`](/documentation/UIKit/NSLayoutAnchor) must now take a matching [`NSLayoutDimension`](/documentation/UIKit/NSLayoutDimension) object.

```swift
// This code works as expected.
saveButton.widthAnchor.constraint(equalTo: cancelButton.widthAnchor).isActive = true

// This code generates an incompatible pointer type warning.
saveButton.widthAnchor.constraint(equalTo: cancelButton.leadingAnchor).isActive = true
```

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

## Topics

### Building constraints

[`-  constraintEqualToAnchor:multiplier:`](/documentation/UIKit/NSLayoutDimension/constraint(equalTo:multiplier:))

Returns a constraint that defines the anchor’s size attribute as equal to the specified anchor multiplied by the constant.

[`-  constraintEqualToAnchor:multiplier:constant:`](/documentation/UIKit/NSLayoutDimension/constraint(equalTo:multiplier:constant:))

Returns a constraint that defines the anchor’s size attribute as equal to the specified size attribute multiplied by a constant plus an offset.

[`-  constraintEqualToConstant:`](/documentation/UIKit/NSLayoutDimension/constraint(equalToConstant:))

Returns a constraint that defines a constant size for the anchor’s size attribute.

[`-  constraintGreaterThanOrEqualToAnchor:multiplier:`](/documentation/UIKit/NSLayoutDimension/constraint(greaterThanOrEqualTo:multiplier:))

Returns a constraint that defines the anchor’s size attribute as greater than or equal to the specified anchor multiplied by the constant.

[`-  constraintGreaterThanOrEqualToAnchor:multiplier:constant:`](/documentation/UIKit/NSLayoutDimension/constraint(greaterThanOrEqualTo:multiplier:constant:))

Returns a constraint that defines the anchor’s size attribute as greater than or equal to the specified anchor multiplied by the constant plus an offset.

[`-  constraintGreaterThanOrEqualToConstant:`](/documentation/UIKit/NSLayoutDimension/constraint(greaterThanOrEqualToConstant:))

Returns a constraint that defines the minimum size for the anchor’s size attribute.

[`-  constraintLessThanOrEqualToAnchor:multiplier:`](/documentation/UIKit/NSLayoutDimension/constraint(lessThanOrEqualTo:multiplier:))

Returns a constraint that defines the anchor’s size attribute as less than or equal to the specified anchor multiplied by the constant.

[`-  constraintLessThanOrEqualToAnchor:multiplier:constant:`](/documentation/UIKit/NSLayoutDimension/constraint(lessThanOrEqualTo:multiplier:constant:))

Returns a constraint that defines the anchor’s size attribute as greater than or equal to the specified anchor multiplied by the constant plus an offset.

[`-  constraintLessThanOrEqualToConstant:`](/documentation/UIKit/NSLayoutDimension/constraint(lessThanOrEqualToConstant:))

Returns a constraint that defines the maximum size for the anchor’s size attribute.

## Relationships

### Conforms To

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

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

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

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

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

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

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

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

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

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

### Inherits From

[`NSLayoutAnchor`](/documentation/UIKit/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)