Autolayout: why are these same restrictions different from each other?

I am researching autorun. I am currently adding a simple constraint: 0px margin between view and superview.

There seem to be two ways to add this constraint:

First click on the bottom right button of your xib editor, select the left margin and click add n constraints like in this screenshot: first way to add constraint

Here are the first properties of the constraint. It has a persistent 16px margin:
enter image description here

Second way, choose from the Xcode menu: Editor> Output> Lead Space to Watch:
The second way

Now my limit is 0px, but it works too: the view is well adapted to suit its superview

Here's my next constraint properties:
enter image description here

First question: why my first left and right margin is 16px ? I am working on a brand new project! If I set it to 0px there is extra space around my view!

Second question: what's the difference between these two restrictions? What's the best method?

thank

0


source to share


1 answer


You have already answered. The limit for the supervisor is not the same as the limit for the supervisor token.

This might be easiest if you think about how to shape these constraints in code. Here are the attributes you can use:



https://developer.apple.com/Library/ios/documentation/AppKit/Reference/NSLayoutConstraint_Class/index.html#//apple_ref/c/tdef/NSLayoutAttribute

As you can see, there are both Right and RightMargin. Snaps the right edge of the subview to its oversight. A rule is not the same as tying it to its right-to-right right.

+1


source







All Articles