Learn how to adjust the size automatically in automatic layout today.
First, size classification
Dimension classification is a kind of approximate classification of equipment width and height.
There are two specific size classifications used to represent the real machine: compact and Standard (Regular). There is also a third classification that can be both compact or standard in the design tool and in the code: any
The following are illustrations of dimension classification and device orientation
Familiarity with dimensional classifications is essential to the design of your application.
We need to use the dimension classification control when we design,
Second, the following records how to change from vertical to horizontal, and the position of the control can be changed adaptive layout
1. Select the appropriate size type, here is an example of the size type of iphone5s
2. Re-move the controls for initial layout
3. Uninstall the constraint that is already in the current panel when the vertical screen is ready
Take action one as an example to unload the view Control and 4 button constraints
1) Select action One to open the dimension Inspector
2) Double-click the first constraint in constraints, click the plus sign in front of the installed check box at the bottom to select any with | Compact Height, add a new check box for Wany and hcompact layouts only. Cancel his tick to unload this constraint from this size grouping, which is still valid in the general designer.
4. Adding constraints to the new design
1) Green view, click the Pin button, uncheck the Constrain to Margins checkbox, click the red dotted line above the square, left, below, and fill in the text box 20, and finally click the Add 3 Constraints button.
On the right side of the fixed green view, just press and hold the right button, drag from the view to the right, until the main viewing background is blue, release, and select the trailing Space to Container margin option.
2) button, you need to align 4 buttons in one column, and the same distance is spaced. Several view controls are required. By adding a hidden fill view to the button gap, the views occupy all available space and have the same height, so that all buttons have the same height and the final result.
① Add a Fill view to select the color of the view as Gray
② Select all the Fill views, click the Pin button, tick the equal widths and equal Heights and select the left and right dashed lines, and fill in the text box with 0, and finally click Add Constraints
③ let the fill view and buttons align on the same vertical line, select all the Fill views and buttons, press the Align button, tick the horizontal Centers check box, and then click the Add 8 contraints button.
④ Make sure that the view occupies all the vertical space between the buttons and the space between the top button and the bottom button and the main view. We can achieve this effect by setting the distance between each of the two views to be zero.
Select all fill views and click the Pin button, select the red dashed line up and down in the pop-up panel, fill in the text box with 0, and then click the Add Contraints button.
⑤ Select the Update frames option, editor, Resolve Auto Layout issues, you are done!
Note: Finally, don't forget to hide the fill view, check the fill view, and tick the hidden check box in the drawing in the property inspector.
Proficient in iOS development-note4