Instance Method

constraintLessThanOrEqualToConstant:

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

Declaration

- (NSLayoutConstraint *)constraintLessThanOrEqualToConstant:(CGFloat)c;

Parameters

c

A constant representing the maximum size of the attribute associated with this dimension anchor.

Return Value

An NSLayoutConstraint object that defines a maximum size for the attribute associated with this dimension anchor.

Discussion

This method defines the relationship first attribute <= c. Where first attribute is the layout attribute represented by the anchor receiving this method call.

The constraints produced by the following two examples are identical.

// Creating a constraint using NSLayoutConstraint
[NSLayoutConstraint
 constraintWithItem:self.button
 attribute:NSLayoutAttributeWidth
 relatedBy:NSLayoutRelationLessThanOrEqual
 toItem:nil
 attribute:NSLayoutAttributeNotAnAttribute
 multiplier:1.0
 constant:40.0].active = YES;
 
// Creating the same constraint using constraintLessThanOrEqualToConstant:
[self.button.widthAnchor constraintLessThanOrEqualToConstant: 40.0].active = YES;

See Also

Building Constraints

- constraintEqualToAnchor:multiplier:

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

- constraintEqualToAnchor:multiplier:constant:

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

- constraintEqualToConstant:

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

- constraintGreaterThanOrEqualToAnchor:multiplier:

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

- constraintGreaterThanOrEqualToAnchor:multiplier:constant:

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.

- constraintGreaterThanOrEqualToConstant:

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

- constraintLessThanOrEqualToAnchor:multiplier:

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

- constraintLessThanOrEqualToAnchor:multiplier:constant:

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.