At first, when I was working, I used SB interface development for a period of time. Later, I changed the team to pure code layout. Now for some modules of visual layout development, so summarize the original constraints of the use of methods, learn from the past.
- Constraint Priority
As shown above, constraints 1 and 2 of the label control represent left and right constraints.
Click on a specific constraint and the details of the constraint are displayed on the right. The value of Priority is the priority of this constraint, which is divided into three categories: required (1000) is the default proportion level, high (750) is the high priority and low (250) is the low priority. The higher the value, the stronger the priority.
For example, the No. 1 constraint priority in the label control is 1000, and the No. 2 constraint priority is 750, which means that the right side of the label is easier to “change” than the left side.
- Tensile properties
Anti-compression means that A control is not stretched or deformed by other controls relative to the constraints set by A control. In sb, this property is shown as follows:
The hugging property is the tensile property, which has two options: compression resistance in horizontal direction and compression resistance priority in vertical direction.
For example, when the hugging value of the control is 250 horizontally, its own anti-stretching priority is lower than the priority of the constraints on both sides. If the content of the control is more than the “volume” that the current control can hold, or the value of the left and right constraints is smaller at the moment, the control will be stretched.
- Anti-compression property
Anti-compression means that A control is not compressed or deformed by other controls relative to the constraints set by A control. In sb, this property is shown as follows:
Content Compression attribute is anti-compression attribute, which has two options: horizontal anti-compression and vertical anti-compression priority.
For example, when the compression value of the control is below 1000 horizontally and the priority of constraint 2 is 1000, then when the spatial content of constraint 2 on the right becomes larger, constraint 2 will “squeeze” the label control to the left, because its compression value is not enough to oppose the priority value of constraint 2.