Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "Constrain to margins" mean in Interface Builder in Xcode 6.0.1

I understand the purpose of "Spacing to the nearest neighbor" (in Xcode 6, more especially in Interface Builder) but what is the point of "Constrain to margins"?

Is there a link between "Spacing to the nearest neighbor" an edge of a particular control button, and the fact of at the same time checking the checkbox named "Constrain to margins"?

What is the role of this feature in Autolayout?

Please find a screenshot with the checkbox and the label that I am talking about surrounded in red below:

Constrain to margins screenshot

(Screenshot above in bigger format)

Thank you in advance for your answers to my three questions.

like image 465
King-Wizard Avatar asked Oct 10 '14 05:10

King-Wizard


People also ask

What is constrain to margin in Xcode?

Basically if the layout margins are 8,8,8,8 (the default), a constraint with 0 leading space to container margin will have an x position of 8. Note that this is only available on iOS8 or later.

What does constrain to margins do?

By unchecking "constraints to margin", you are adding constraints, meaning your interface will react correctly to changes in size or orientation.

What is Autolayout Xcode?

Auto layout will help keep the button central in different orientations and devices. It is a constraint-based layout system that allows developers to create an adaptive interface, that responds appropriately to changes in screen size and device orientation.


1 Answers

iOS8 introduces a new property of the UIView: layoutMargins. Shortly: these 4 values (a UIEdgeInsets) represent the margins of the view: its subviews can now be positioned relative to these margins, or the old way relative to the sides. I wrote an article about this in my blog with more details, let me know if it is clear and if you have additional doubts.

like image 170
valfer Avatar answered Sep 27 '22 22:09

valfer