Class

NSLayoutDimension

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

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 NSLayoutAnchor. Specifically, the generic methods declared by NSLayoutAnchor must now take a matching NSLayoutDimension 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 NSLayoutAnchor.

Topics

Building Constraints

func constraint(equalTo: NSLayoutDimension, multiplier: CGFloat)

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

func constraint(equalTo: NSLayoutDimension, multiplier: CGFloat, constant: CGFloat)

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

func constraint(equalToConstant: CGFloat)

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

func constraint(greaterThanOrEqualTo: NSLayoutDimension, multiplier: CGFloat)

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

func constraint(greaterThanOrEqualTo: NSLayoutDimension, multiplier: CGFloat, constant: CGFloat)

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.

func constraint(greaterThanOrEqualToConstant: CGFloat)

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

func constraint(lessThanOrEqualTo: NSLayoutDimension, multiplier: CGFloat)

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

func constraint(lessThanOrEqualTo: NSLayoutDimension, multiplier: CGFloat, constant: CGFloat)

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.

func constraint(lessThanOrEqualToConstant: CGFloat)

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

Relationships

Inherits From

See Also

Layout Guides

class UILayoutGuide

A rectangular area that can interact with Auto Layout.