A factory class for creating size-based layout constraint objects using a fluent API.
SDKs
- iOS 9.0+
- macOS 10.11+
- Mac Catalyst 13.0+
- tvOS 9.0+
Frameworks
- UIKit
- App
Kit
Declaration
class NSLayoutDimension : NSLayout Anchor<NSLayout Dimension>
Overview
Use these constraints to programatically 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 NSLayout
. Specifically, the generic methods declared by NSLayout
must now take a matching NSLayout
object.
// This works as expected.
saveButton.widthAnchor.constraintEqualToAnchor(cancelButton.widthAnchor).active = true
// This generates an incompatible pointer type warning.
saveButton.widthAnchor.constraintEqualToAnchor(cancelButton.leadingAnchor).active = true
For more information on using layout anchors, see NSLayout
.