init(item:attribute:relatedBy:toItem:attribute:multiplier:constant:)
Creates a constraint that defines the relationship between the specified attributes of the given views.
Declaration
convenience init(item view1: Any, attribute attr1: NSLayoutConstraint.Attribute, relatedBy relation: NSLayoutConstraint.Relation, toItem view2: Any?, attribute attr2: NSLayoutConstraint.Attribute, multiplier: CGFloat, constant c: CGFloat)Parameters
- view1:
The view for the left side of the constraint.
- attr1:
The attribute of the view for the left side of the constraint.
- relation:
The relationship between the left side of the constraint and the right side of the constraint.
- view2:
The view for the right side of the constraint.
- attr2:
The attribute of the view for the right side of the constraint.
- multiplier:
The constant multiplied with the attribute on the right side of the constraint as part of getting the modified attribute.
- c:
The constant added to the multiplied attribute value on the right side of the constraint to yield the final modified attribute.
Return Value
A constraint object relating the two provided views with the specified relation, attributes, multiplier, and constant.
Discussion
Constraints represent linear equations of the form view1.attr1 <relation> multiplier × view2.attr2 + c. If the constraint you wish to express does not have a second view and attribute, use nil and NSLayoutConstraint.Attribute.notAnAttribute.