Class

NSLayoutXAxisAnchor

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

Declaration

class NSLayoutXAxisAnchor : NSLayoutAnchor<NSLayoutXAxisAnchor>

Overview

NSLayoutXAxisAnchor adds type information to the methods inherited from NSLayoutAnchor. Specifically, the generic methods declared by NSLayoutAnchor must now take a matching NSLayoutXAxisAnchor object.

// This constraint is valid
cancelButton.leadingAnchor.constraintEqualToAnchor(saveButton.trailingAnchor, constant: 8.0).active = true
 
// This constraint generates an incompatible pointer type warning
cancelButton.leadingAnchor.constraintEqualToAnchor(saveButton.topAnchor, constant: 8.0).active = true

For more information on using layout anchors, see NSLayoutAnchor.

Topics

Building System Spacing Constraints

func constraint(equalToSystemSpacingAfter: NSLayoutXAxisAnchor, multiplier: CGFloat) -> NSLayoutConstraint

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

func constraint(greaterThanOrEqualToSystemSpacingAfter: NSLayoutXAxisAnchor, multiplier: CGFloat) -> NSLayoutConstraint

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

Creating Self-Sizing Table View Cells

Create table view cells that support Dynamic Type and use system spacing constraints to adjust the spacing surrounding text labels.

Creating a Layout Dimension

func anchorWithOffset(to: NSLayoutXAxisAnchor) -> NSLayoutDimension

Creates a layout dimension object from two anchors.

Relationships

Inherits From

Conforms To

See Also

Anchors

class NSLayoutAnchor

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

class NSLayoutYAxisAnchor

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

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software