Search code examples
iosxcode-storyboard

Why does Leading/Trailing space show as -16?


As I updated my Xcode from version 5 to 6 I saw a strange things in the storyboard. Here is one example:

  • What my requirement was - I wanted no space between my view and the container view.
  • What I did - I dragged the views left/right edge so that it meets the container margin. And then I put a horizontal spacing constraint.

Earlier the value used to be - Leading/Trailing Space to:Superview Equals:0

Now after updating to Xcode 6 it always shows - Leading/Trailing Space to:Superview Equals:-16.000000

Why does this happen?


Solution

  • That's container's margin. I think it applies the default margin to the edges. If you want to set up the Leading/Trailing Space to Superview constraint then you can do so.

    enter image description here

    If you have already created the constraint then you can select that constraint and uncheck Relative to margin

    enter image description here

    Please note the Relative to margin feature is only available on iOS >= 8, the app will crash (not sure but it should) on iOS < 8.