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

# priority

The priority of the constraint.

```
var priority: UILayoutPriority { get set }
```

## Discussion

By default, all constraints are required; this property is set to <doc://com.apple.documentation/documentation/AppKit/NSLayoutConstraint/Priority-swift.struct/required> in macOS or `UILayoutPriorityRequired` in iOS.

If a constraint’s priority level is less than <doc://com.apple.documentation/documentation/AppKit/NSLayoutConstraint/Priority-swift.struct/required> in macOS or `UILayoutPriorityRequired` in iOS, then it is optional. Higher priority constraints are satisfied before lower priority constraints; however, optional constraint satisfaction is not all or nothing. If a constraint `a == b` is optional, the constraint-based layout system will attempt to minimize `abs(a-b)`.

Priorities may not change from nonrequired to required, or from required to nonrequired. An exception will be thrown if a priority of <doc://com.apple.documentation/documentation/AppKit/NSLayoutConstraint/Priority-swift.struct/required> in macOS or `UILayoutPriorityRequired` in iOS is changed to a lower priority, or if a lower priority is changed to a required priority after the constraints is added to a view. Changing from one optional priority to another optional priority is allowed even after the constraint is installed on a view.

Priorities must be greater than 0 and less than or equal to <doc://com.apple.documentation/documentation/AppKit/NSLayoutConstraint/Priority-swift.struct/required> in macOS or `UILayoutPriorityRequired` in iOS.

---

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)