One, use AutoLayout for relative layout:
1. Create a new project, set up Rootviewcontroller (no more speaking here)
2. Tick below (as we are using sizeclass below, so tick two):
3. Here I created a lable, named View1, where you can see that the settings View1 are constrained to the upper and the left 0, and the width and height settings are 200, so you can set the right and bottom constraints,
4. When the above work is done, click the Add button and a yellow constraint will appear, such as:
5. Click Update Frames After the above work is complete, and the constraint to this View1 is created. When we want to change the constraint, we need to clear the original constraint, click on the clear Constraints, add the constraint from the new.
6. At this point, I created a lable called VIEW2, which also sets the constraint to 8 from the left (that is, 8 from the View1), 8 to the right margin, and 96 for the height.
7. Tap Add to add a constraint,
8. Update Fream is OK,
9. Similarly, create VIEW3 lable, in order to save everyone time, do not operate at every step, so far, the basic AutoLayout use has been described, you can run to see the effect.
Second, the use of Sizeclass
1, then the above example, we can find that at the bottom, there are Wany HAny, click Wany, we can see that this is the support of all the screen settings, the disadvantage is not exquisite, when we cross-screen how to do? (For a detailed resolution of size class, refer to the Apple documentation):
2. When we are in the horizontal screen to adapt to the screen, then, for example, choose the following way:
3. Change the properties, set the length and height, where I changed the height of the View1, such as:
4, change the height of View2 and View3, match with View1, for example:
After the modification is complete, run debugging, which is the result you want. Of course, this example only has two screens to fit, so you can fit 9 different kinds of apple screens.
There may be a lot of things in this article, and I hope the great God will criticize you.
IOS 8 Auto-layout Sizeclass and AutoLayout use