14

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.

King-Wizard
  • 15,628
  • 6
  • 82
  • 76
  • 1
    possible duplicate of [What is "Constrain to margin" in Storyboard in Xcode 6](http://stackoverflow.com/questions/25807545/what-is-constrain-to-margin-in-storyboard-in-xcode-6) – Lord Zsolt Oct 10 '14 at 06:06
  • I have checked the link of the post but the best explanation is: "in iOS 8 you now have the option to define your constrains relative to a predefined margin to the superview's bounds, instead of the superview's bounds themselves.". Sorry but it is not clear and does not mean anything for me, that is why I ask to clarify this obscure answer and explanation. – King-Wizard Oct 10 '14 at 06:36

1 Answers1

23

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.

valfer
  • 3,545
  • 2
  • 19
  • 24
  • Thank you very much dude, I will study the article on your blog and will let you know. – King-Wizard Oct 10 '14 at 14:27
  • 3
    My god am i glad i found this. The -16 pixel stuff was driving me crazy as things were not working on iPhone 6 plus. Removing the relative to margin on the constraints fixed it, thank you! – mobob Oct 25 '14 at 15:50