Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do "Use standard value” and “Constrain to Margins" mean in Auto Layout?

I have gone through a couple of Auto Layout tutorials such as this. However I am still not clear on what the following options do in the pin dialog

enter image description here

  1. What are the differences between standard value, manual values, and canvas values?

  2. What does the constrain to margin checkbox do?

  3. What does align do?

like image 294
James Franco Avatar asked Apr 17 '15 17:04

James Franco


People also ask

What does constrain to margins mean?

The “Constrain to margins” checkbox determines whether constraints to the superview use the superview's margins or its edges.

What are auto layout constraints?

Constraints allow you to control how objects respond to changing frames, while auto layout allows you to control how frames respond to changing objects. In this article, I'll explain how they work and when to use each.

What is the use of auto layout?

Auto Layout defines your user interface using a series of constraints. Constraints typically represent a relationship between two views. Auto Layout then calculates the size and location of each view based on these constraints. This produces layouts that dynamically respond to both internal and external changes.

What is vary trait in auto layout?

Trait Variation is a change to the presentation of your user interface that is based on a device configuration. Trait Variations of the user interface is not just limited to constraints but can be applied to much more.


1 Answers

What are the differences between standard value, manual values, and canvas values?

Standard value uses "the recommended spacing for constraints that specify distance between items", which is usually around 10 points.

Current canvas value copies the value from how you have the objects currently displayed on the canvas.

Manual values are whatever you want.


What does the constrain to margin checkbox do?

This constrains to a container view's margins instead of its edges. From the docs:

“Horizontal and vertical constraints to a container view can be to the margin or to the edge. Margins correspond to the values in the layoutMargins atttribute of UIView and specify recommended minimal distances between an edge of a container view and the corresponding edge of a child.”

You can set a view's margins using the layoutMargins property.


What does align do?

This creates a constraint that edges or center of one view should be aligned with edges or center of another view. For example, in a column of text views, you might want every text field to have their leading and trailing edges aligned.

like image 74
Aaron Brager Avatar answered Oct 13 '22 17:10

Aaron Brager