AutoLayout Automatic Layout technology
After the introduction of AutoLayout , AutoLayout technology is more convenient to solve the iOS system in a variety of screen size adaptation problems, with the improvement of the function is not difficult to see Apple is also in the main push this automatic layout of the technology
The two points that AutoLayout must understand are:
1. Referential
2. Constraint conditions
AutoLayout and frame must choose from two, so-called fish and bear Paw can not be combined.
In fact, AutoLayout technology is the same as the final goal to achieve by reference and constraint-that is, to set the control's position in the parent control.
Let's take a look at the example below:
We're going to set the button's position in the controller.
123
At the bottom left, click on the two-grid stack of markers to see that the bottoms are horizontally aligned and aligned vertically, with our choice of horizontal alignment as an example, and then select within the update frame, items of new constraints We then select Add 1 The Constaint option updates the location of the button, but the effect is not the same as we imagined. The center is centered but the height changes because we haven't set up his other location information, you have to know the control's width height and horizontal ordinate when the control is displayed correctly on the parent control, and then we continue to set it. 4.
Then we select the second option below, click on the red dashed line on the cross, when it becomes solid, I enter 60 in the upper box, which means that the distance above him is 60 (equal to its Y coordinate is determined to be 60), Click on the width and height below to set its width to 100 and 30 respectively, because the width has been determined plus we have previously set the center, so it is equivalent to determine its x-coordinate, so that X,y,width,height has a value that is to determine his position.
5.
Complete
AutoLayout Automatic Layout