What does the multiplier, which is a property of a constraint in Auto Layout, do?
The relationship between two values in a constraint is determined by a formula:
b = am + c
where a and b are the two values that are to be related, m is the multiplier, and c is the constant.
So for example if one width is to be twice that of another, clearly a multiplier of 2 is going to make sense (and a constant of 0). But if one width is to be 10 more than another, then a constant of 10 is going to make sense (and a multiplier of 1).
The default, obviously, is the multiplier is 1 and the constant is 0. That makes a and b equal.
Extra for experts: Under the hood, part of the reason for the structure of this formula is that you end up with a set of simultaneous linear equations to solve for. This is how the various constraints are resolved to get the actual layout.
According to Apple's docs: "The constant multiplied with the attribute on the right-hand side of the constraint as part of getting the modified attribute."
It is useful, for instance, if you want one view's height to be 35% of another view's height. In this case, you'd create a constraint making their heights equal with a multiplier of 0.35.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With