Functions

The following functions are available globally.

  • Declares a property equal to a numerical constant.

    Declaration

    Swift

    @discardableResult public func == (lhs: NumericalEquality, rhs: CGFloat) -> NSLayoutConstraint

    Parameters

    lhs

    The affected property. The associated view will have translatesAutoresizingMaskIntoConstraints set to false.

    rhs

    The numerical constant.

    Return Value

    An NSLayoutConstraint.

  • Declares a property equal to a the result of an expression.

    See more

    Declaration

    Swift

    @discardableResult public func == <P: RelativeEquality>(lhs: P, rhs: Expression<P>) -> NSLayoutConstraint

    Parameters

    lhs

    The affected property. The associated view will have translatesAutoresizingMaskIntoConstraints set to false.

    rhs

    The expression.

    Return Value

    An NSLayoutConstraint.

  • Declares a property equal to another property.

    See more

    Declaration

    Swift

    @discardableResult public func == <P: RelativeEquality>(lhs: P, rhs: P) -> NSLayoutConstraint

    Parameters

    lhs

    The affected property. The associated view will have translatesAutoresizingMaskIntoConstraints set to false.

    rhs

    The other property.

  • Declares a property less than or equal to a numerical constant.

    Declaration

    Swift

    @discardableResult public func <= (lhs: NumericalInequality, rhs: CGFloat) -> NSLayoutConstraint

    Parameters

    lhs

    The affected property. The associated view will have translatesAutoresizingMaskIntoConstraints set to false.

    rhs

    The numerical constant.

    Return Value

    An NSLayoutConstraint.

  • Declares a property greater than or equal to a numerical constant.

    Declaration

    Swift

    @discardableResult public func >= (lhs: NumericalInequality, rhs: CGFloat) -> NSLayoutConstraint

    Parameters

    lhs

    The affected property. The associated view will have translatesAutoresizingMaskIntoConstraints set to false.

    rhs

    The numerical constant.

    Return Value

    An NSLayoutConstraint.

  • Declares a property less than or equal to another property.

    See more

    Declaration

    Swift

    @discardableResult public func <= <P: RelativeInequality>(lhs: P, rhs: P) -> NSLayoutConstraint

    Parameters

    lhs

    The affected property. The associated view will have translatesAutoresizingMaskIntoConstraints set to false.

    rhs

    The other property.

    Return Value

    An NSLayoutConstraint.

  • Declares a property greater than or equal to another property.

    See more

    Declaration

    Swift

    @discardableResult public func >= <P: RelativeInequality>(lhs: P, rhs: P) -> NSLayoutConstraint

    Parameters

    lhs

    The affected property. The associated view will have translatesAutoresizingMaskIntoConstraints set to false.

    rhs

    The other property.

    Return Value

    An NSLayoutConstraint.

  • Declares a property less than or equal to the result of an expression.

    See more

    Declaration

    Swift

    @discardableResult public func <= <P: RelativeInequality>(lhs: P, rhs: Expression<P>) -> NSLayoutConstraint

    Parameters

    lhs

    The affected property. The associated view will have translatesAutoresizingMaskIntoConstraints set to false.

    rhs

    The other property.

    Return Value

    An NSLayoutConstraint.

  • Declares a property greater than or equal to the result of an expression.

    See more

    Declaration

    Swift

    @discardableResult public func >= <P: RelativeInequality>(lhs: P, rhs: Expression<P>) -> NSLayoutConstraint

    Parameters

    lhs

    The affected property. The associated view will have translatesAutoresizingMaskIntoConstraints set to false.

    rhs

    The other property.

    Return Value

    An NSLayoutConstraint.

  • Sets the priority for a constraint.

    Declaration

    Swift

    @discardableResult public func ~ (lhs: NSLayoutConstraint, rhs: LayoutPriority) -> NSLayoutConstraint

    Parameters

    lhs

    The constraint to update.

    rhs

    The new priority.

    Return Value

    The same constraint with its priority updated.

  • Sets the priority for multiple constraints.

    Declaration

    Swift

    @discardableResult public func ~ (lhs: [NSLayoutConstraint], rhs: LayoutPriority) -> [NSLayoutConstraint]

    Parameters

    lhs

    An array of NSLayoutConstraint instances.

    rhs

    The new priority.

    Return Value

    The same constraints with their priorities updated.

  • Insets all edges.

    Declaration

    Swift

    public func inset(_ edges: Edges, _ all: CGFloat) -> Expression<Edges>

    Parameters

    edges

    The edges to inset.

    all

    The amount by which to inset all edges, in points.

    Return Value

    A new expression with the inset edges.

  • Insets the horizontal and vertical edges.

    Declaration

    Swift

    public func inset(_ edges: Edges, _ horizontal: CGFloat, _ vertical: CGFloat) -> Expression<Edges>

    Parameters

    edges

    The edges to inset.

    horizontal

    The amount by which to inset the horizontal edges, in points.

    vertical

    The amount by which to inset the vertical edges, in points.

    Return Value

    A new expression with the inset edges.

  • Insets edges individually.

    Declaration

    Swift

    public func inset(_ edges: Edges, _ top: CGFloat, _ leading: CGFloat, _ bottom: CGFloat, _ trailing: CGFloat) -> Expression<Edges>

    Parameters

    edges

    The edges to inset.

    top

    The amount by which to inset the top edge, in points.

    leading

    The amount by which to inset the leading edge, in points.

    bottom

    The amount by which to inset the bottom edge, in points.

    trailing

    The amount by which to inset the trailing edge, in points.

    Return Value

    A new expression with the inset edges.

  • Insets edges individually with UIEdgeInset.

    Declaration

    Swift

    public func inset(_ edges: Edges, _ insets: UIEdgeInsets) -> Expression<Edges>

    Parameters

    edges

    The edges to inset.

    insets

    The amounts by which to inset all edges, in points via UIEdgeInsets.

    Return Value

    A new expression with the inset edges.

  • Updates the constraints of a single view.

    Declaration

    Swift

    @discardableResult public func constrain(_ view: View, replace group: ConstraintGroup? = nil, block: (LayoutProxy) -> ()) -> ConstraintGroup

    Parameters

    view

    The view to layout.

    replace

    The ConstraintGroup whose constraints should be replaced.

    block

    A block that declares the layout for view.

  • Updates the constraints of two views.

    Declaration

    Swift

    @discardableResult public func constrain(_ view1: View, _ view2: View, replace group: ConstraintGroup? = nil, block: (LayoutProxy, LayoutProxy) -> ()) -> ConstraintGroup

    Parameters

    view1

    A view to layout.

    view2

    A view to layout.

    replace

    The ConstraintGroup whose constraints should be replaced.

    block

    A block that declares the layout for the views.

  • Updates the constraints of three views.

    Declaration

    Swift

    @discardableResult public func constrain(_ view1: View, _ view2: View, _ view3: View, replace group: ConstraintGroup? = nil, block: (LayoutProxy, LayoutProxy, LayoutProxy) -> ()) -> ConstraintGroup

    Parameters

    view1

    A view to layout.

    view2

    A view to layout.

    view3

    A view to layout.

    replace

    The ConstraintGroup whose constraints should be replaced.

    block

    A block that declares the layout for the views.

  • Updates the constraints of four views.

    Declaration

    Swift

    @discardableResult public func constrain(_ view1: View, _ view2: View, _ view3: View, _ view4: View, replace group: ConstraintGroup? = nil, block: (LayoutProxy, LayoutProxy, LayoutProxy, LayoutProxy) -> ()) -> ConstraintGroup

    Parameters

    view1

    A view to layout.

    view2

    A view to layout.

    view3

    A view to layout.

    view4

    A view to layout.

    replace

    The ConstraintGroup whose constraints should be replaced.

    block

    A block that declares the layout for the views.

  • Updates the constraints of five views.

    Declaration

    Swift

    @discardableResult public func constrain(_ view1: View, _ view2: View, _ view3: View, _ view4: View, _ view5: View, replace group: ConstraintGroup? = nil, block: (LayoutProxy, LayoutProxy, LayoutProxy, LayoutProxy, LayoutProxy) -> ()) -> ConstraintGroup

    Parameters

    view1

    A view to layout.

    view2

    A view to layout.

    view3

    A view to layout.

    view4

    A view to layout.

    view5

    A view to layout.

    replace

    The ConstraintGroup whose constraints should be replaced.

    block

    A block that declares the layout for the views.

  • Updates the constraints of an array of views.

    Declaration

    Swift

    @discardableResult public func constrain(_ views: [View], replace group: ConstraintGroup? = nil, block: ([LayoutProxy]) -> ()) -> ConstraintGroup

    Parameters

    views

    The views to layout.

    replace

    The ConstraintGroup whose constraints should be replaced.

    block

    A block that declares the layout for views.

  • Updates the constraints of a dictionary of views.

    Declaration

    Swift

    @discardableResult public func constrain<T: Hashable>(_ views: [T: View], replace group: ConstraintGroup? = nil, block: (([T : LayoutProxy]) -> ())) -> ConstraintGroup

    Parameters

    views

    The views to layout.

    replace

    The ConstraintGroup whose constraints should be replaced.

    block

    A block that declares the layout for views.

  • Removes all constraints for a group.

    Declaration

    Swift

    @discardableResult public func constrain(clear group: ConstraintGroup)

    Parameters

    clear

    The ConstraintGroup whose constraints should be removed.

  • Distributes multiple views horizontally.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func distribute(by amount: CGFloat = 0.0, horizontally views: [LayoutProxy]) -> [NSLayoutConstraint]

    Parameters

    amount

    The distance between the views.

    views

    An array of views to distribute.

    Return Value

    An array of NSLayoutConstraint instances.

  • Distributes multiple views horizontally from left to right.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func distribute(by amount: CGFloat = 0.0, leftToRight views: [LayoutProxy]) -> [NSLayoutConstraint]

    Parameters

    amount

    The distance between the views.

    views

    An array of views to distribute.

    Return Value

    An array of NSLayoutConstraint instances.

  • Distributes multiple views vertically.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func distribute(by amount: CGFloat = 0.0, vertically views: [LayoutProxy]) -> [NSLayoutConstraint]

    Parameters

    amount

    The distance between the views.

    views

    An array of views to distribute.

    Return Value

    An array of NSLayoutConstraint instances.

  • Distributes multiple views horizontally.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func distribute(by amount: CGFloat = 0.0, horizontally first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint]

    Parameters

    amount

    The distance between the views.

    views

    The views to distribute.

    Return Value

    An array of NSLayoutConstraint instances.

  • Distributes multiple views horizontally from left to right.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func distribute(by amount: CGFloat = 0.0, leftToRight first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint]

    Parameters

    amount

    The distance between the views.

    views

    The views to distribute.

    Return Value

    An array of NSLayoutConstraint instances.

  • Distributes multiple views vertically.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func distribute(by amount: CGFloat = 0.0, vertically first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint]

    Parameters

    amount

    The distance between the views.

    views

    The views to distribute.

    Return Value

    An array of NSLayoutConstraint instances.

  • Declares a property equal to a the result of an expression.

    See more

    Declaration

    Swift

    @discardableResult public func == <P: RelativeCompoundEquality>(lhs: P, rhs: Expression<P>) -> [NSLayoutConstraint]

    Parameters

    lhs

    The affected property. The associated view will have translatesAutoresizingMaskIntoConstraints set to false.

    rhs

    The expression.

    Return Value

    An NSLayoutConstraint.

  • Declares a property equal to another compound property.

    See more

    Declaration

    Swift

    @discardableResult public func == <P: RelativeCompoundEquality>(lhs: P, rhs: P) -> [NSLayoutConstraint]

    Parameters

    lhs

    The affected property. The associated view will have translatesAutoresizingMaskIntoConstraints set to false.

    rhs

    The other property.

  • Declares a property less than or equal to another compound property.

    See more

    Declaration

    Swift

    @discardableResult public func <= <P: RelativeCompoundInequality>(lhs: P, rhs: P) -> [NSLayoutConstraint]

    Parameters

    lhs

    The affected property. The associated view will have translatesAutoresizingMaskIntoConstraints set to false.

    rhs

    The other property.

    Return Value

    An NSLayoutConstraint.

  • Declares a property greater than or equal to another compound property.

    See more

    Declaration

    Swift

    @discardableResult public func >= <P: RelativeCompoundInequality>(lhs: P, rhs: P) -> [NSLayoutConstraint]

    Parameters

    lhs

    The affected property. The associated view will have translatesAutoresizingMaskIntoConstraints set to false.

    rhs

    The other property.

    Return Value

    An NSLayoutConstraint.

  • Declares a property less than or equal to the result of an expression.

    See more

    Declaration

    Swift

    @discardableResult public func <= <P: RelativeCompoundInequality>(lhs: P, rhs: Expression<P>) -> [NSLayoutConstraint]

    Parameters

    lhs

    The affected property. The associated view will have translatesAutoresizingMaskIntoConstraints set to false.

    rhs

    The other property.

    Return Value

    An NSLayoutConstraint.

  • Declares a property greater than or equal to the result of an expression.

    See more

    Declaration

    Swift

    @discardableResult public func >= <P: RelativeCompoundInequality>(lhs: P, rhs: Expression<P>) -> [NSLayoutConstraint]

    Parameters

    lhs

    The affected property. The associated view will have translatesAutoresizingMaskIntoConstraints set to false.

    rhs

    The other property.

    Return Value

    An NSLayoutConstraint.

  • Declares a property equal to a layout support.

    See more

    Declaration

    Swift

    @discardableResult public func == <P: RelativeEquality>(lhs: P, rhs: LayoutSupport) -> NSLayoutConstraint

    Parameters

    lhs

    The affected property. The associated view will have translatesAutoresizingMaskIntoConstraints set to false.

    rhs

    The layout support.

    Return Value

    An NSLayoutConstraint.

  • Declares a property equal to the result of a layout support expression.

    See more

    Declaration

    Swift

    @discardableResult public func == <P: RelativeEquality>(lhs: P, rhs: Expression<LayoutSupport>) -> NSLayoutConstraint

    Parameters

    lhs

    The affected property. The associated view will have translatesAutoresizingMaskIntoConstraints set to false.

    rhs

    The layout support expression.

    Return Value

    An NSLayoutConstraint.

  • Declares a property greater than or equal to a layout support.

    See more

    Declaration

    Swift

    @discardableResult public func >= <P: RelativeEquality>(lhs: P, rhs: LayoutSupport) -> NSLayoutConstraint

    Parameters

    lhs

    The affected property. The associated view will have translatesAutoresizingMaskIntoConstraints set to false.

    rhs

    The layout support.

    Return Value

    An NSLayoutConstraint.

  • Declares a property less than or equal to a layout support.

    See more

    Declaration

    Swift

    @discardableResult public func <= <P: RelativeEquality>(lhs: P, rhs: LayoutSupport) -> NSLayoutConstraint

    Parameters

    lhs

    The affected property. The associated view will have translatesAutoresizingMaskIntoConstraints set to false.

    rhs

    The layout support.

    Return Value

    An NSLayoutConstraint.

  • Declares a property greater than or equal to the result of a layout support expression.

    See more

    Declaration

    Swift

    @discardableResult public func >= <P: RelativeEquality>(lhs: P, rhs: Expression<LayoutSupport>) -> NSLayoutConstraint

    Parameters

    lhs

    The affected property. The associated view will have translatesAutoresizingMaskIntoConstraints set to false.

    rhs

    The layout support.

    Return Value

    An NSLayoutConstraint.

  • Declares a property less than or equal to the result of a layout support expression.

    See more

    Declaration

    Swift

    @discardableResult public func <= <P: RelativeEquality>(lhs: P, rhs: Expression<LayoutSupport>) -> NSLayoutConstraint

    Parameters

    lhs

    The affected property. The associated view will have translatesAutoresizingMaskIntoConstraints set to false.

    rhs

    The layout support.

    Return Value

    An NSLayoutConstraint.

  • Aligns multiple views by their top edge.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func align(top views: [LayoutProxy]) -> [NSLayoutConstraint]

    Parameters

    views

    an array of views to align

    Return Value

    An array of NSLayoutConstraint instances.

  • Aligns multiple views by their right edge.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func align(right views: [LayoutProxy]) -> [NSLayoutConstraint]

    Parameters

    views

    an array of views to align

    Return Value

    An array of NSLayoutConstraint instances.

  • Aligns multiple views by their bottom edge.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func align(bottom views: [LayoutProxy]) -> [NSLayoutConstraint]

    Parameters

    views

    an array of views to align

    Return Value

    An array of NSLayoutConstraint instances.

  • Aligns multiple views by their left edge.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func align(left views: [LayoutProxy]) -> [NSLayoutConstraint]

    Parameters

    views

    an array of views to align

    Return Value

    An array of NSLayoutConstraint instances.

  • Aligns multiple views by their leading edge.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func align(leading views: [LayoutProxy]) -> [NSLayoutConstraint]

    Parameters

    views

    an array of views to align

    Return Value

    An array of NSLayoutConstraint instances.

  • Aligns multiple views by their trailing edge.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func align(trailing views: [LayoutProxy]) -> [NSLayoutConstraint]

    Parameters

    views

    an array of views to align

    Return Value

    An array of NSLayoutConstraint instances.

  • Aligns multiple views by their horizontal center.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func align(centerX views: [LayoutProxy]) -> [NSLayoutConstraint]

    Parameters

    views

    an array of views to align

    Return Value

    An array of NSLayoutConstraint instances.

  • Aligns multiple views by their vertical center.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func align(centerY views: [LayoutProxy]) -> [NSLayoutConstraint]

    Parameters

    views

    an array of views to align

    Return Value

    An array of NSLayoutConstraint instances.

  • Aligns multiple views by their baseline.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func align(baseline views: [LayoutProxy]) -> [NSLayoutConstraint]

    Parameters

    views

    an array of views to align

    Return Value

    An array of NSLayoutConstraint instances.

  • Aligns multiple views by their top edge.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func align(top first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint]

    Return Value

    An array of NSLayoutConstraint instances.

  • Aligns multiple views by their right edge.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func align(right first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint]

    Return Value

    An array of NSLayoutConstraint instances.

  • Aligns multiple views by their bottom edge.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func align(bottom first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint]

    Return Value

    An array of NSLayoutConstraint instances.

  • Aligns multiple views by their left edge.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func align(left first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint]

    Return Value

    An array of NSLayoutConstraint instances.

  • Aligns multiple views by their leading edge.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func align(leading first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint]

    Return Value

    An array of NSLayoutConstraint instances.

  • Aligns multiple vies by their trailing edge.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func align(trailing first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint]

    Return Value

    An array of NSLayoutConstraint instances.

  • Aligns multiple views by their horizontal center.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func align(centerX first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint]

    Return Value

    An array of NSLayoutConstraint instances.

  • Aligns multiple views by their vertical center.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func align(centerY first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint]

    Return Value

    An array of NSLayoutConstraint instances.

  • Aligns multiple views by their baseline.

    All views passed to this function will have their translatesAutoresizingMaskIntoConstraints properties set to false.

    Declaration

    Swift

    @discardableResult public func align(baseline first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint]

    Return Value

    An array of NSLayoutConstraint instances.