The percentage of iOS development AutoLayout layout control geometric distance

Multi control level, vertical distribution requires the same spacing, the use of multiplier to layout, that is, the percentage of the layout is the best choice.

Look at this article before you can look at the [iOS NSLayoutConstraint priority][1] which is mentioned in multiplier, the percentage of layout in this paper are based on multiplier, to check the following.


We need to realize the function is very simple, with a middle button as a benchmark, a five button proportionally spaced horizontal distribution effect on the screen as an example, the first constraint center button width of Width and Height, then add Center Horizontally in relative to the parent container (horizontally) and Center Container Vertically in Container (vertical the middle), repeat the above operation is exactly the same of the remaining four buttons.

After the completion, we begin to set apart from other middle button button outside the multiplier, now we will rest four button Center Horizontally in Container multiplier in the constraint from left to right
is set to 0.2, 0.6, 1.4, 1.8, so that it can be achieved by XX times the horizontal position of the parent container width button. The specific value can be set according to demand. The operation steps are as follows:

The percentage of iOS development AutoLayout layout control geometric distance
The percentage of iOS development AutoLayout layout control geometric distance
The percentage of iOS development AutoLayout layout control geometric distance

I use text instead of to a simple explanation on how to set up Multiplier: after we completed the steps above, will see a Align Center X to: on the right side of the constraint, double-click inside can see multiplier.

The specific process is as follows:

The percentage of iOS development AutoLayout layout control geometric distance

There are questions of the students can leave a message in the article or contact my mailbox
Email: shevakuilin@gmail.com

The above content is the basic use of the percentage layout, vertical layout similarly.