horizontal, vertical
top, left, bottom, right
UIEdgeInsets
margin与padding
Interpreting Values
Values in Auto Layout are always in points. However, the exact meaning of these measurements can vary depending on the attributes involved and the view’s layout direction.
Auto Layout Attributes |
Value |
Notes |
---|---|---|
Height Width |
The size of the view. |
These attributes can be assigned constant values or combined with other Height and Width attributes. These values cannot be negative. |
Top Bottom Baseline |
The values increase as you move down the screen. |
These attributes can be combined only with Center Y, Top, Bottom, and Baseline attributes. |
Leading Trailing |
The values increase as you move towards the trailing edge. For a left-to-right layout directions, the values increase as you move to the right. For a right-to-left layout direction, the values increase as you move left. |
These attributes can be combined only with Leading, Trailing, or Center X attributes. |
Left Right |
The values increase as you move to the right. |
These attributes can be combined only with Left, Right, and Center X attributes. Avoid using Left and Right attributes. Use Leading and Trailing instead. This allows the layout to adapt to the view’s reading direction. By default the reading direction is determined based on the current language set by the user. However, you can override this where necessary. In iOS, set the |
Center X Center Y |
The interpretation is based on the other attribute in the equation. |
Center X can be combined with Center X, Leading, Trailing, Right, and Left attributes. Center Y can be combined with Center Y, Top, Bottom, and Baseline attributes. |