AutoLayout Understanding Multiplier

后端 未结 4 539
天涯浪人
天涯浪人 2021-01-17 16:20

I have a problem with multiplier and cannot understand how this feature works. For example i have view has 6:1 multiplier(To SuperView.Leading) as below.

When i

4条回答
  •  梦毁少年i
    2021-01-17 17:25

    Multiplier is there for creating Proportional Constraint. Auto Layout calculates the first item’s attribute to be the product of the second item’s attribute and this multiplier. Any value other than 1 creates a proportional constraint.

    In your case, 6:1 means multiplier is 6/1 = 6. Which means

    view.leading  = Superview.leadingMargin*6
    

    replace : with / - you will understand what it means.

提交回复
热议问题