31

I want to disable automatic adding Relative to margin when creating constraints in IB of Xcode 6.

It's nice that they turn this option on by default, but I have to support iOS7, so it turned out I have to manually disable this option every time after adding new constraint.

I found this setting for disabling it beforehand, but it's always on by default. Adding Constraint in IB

Ossir
  • 3,109
  • 1
  • 34
  • 52

3 Answers3

19

The closest I've ever come to this is hacky at best, so take this for what it is...

Creating AL constraint while not holding Option:

enter image description here

Creating AL constraint while holding option:

enter image description here

In IB if you hold Option while creating the AL constraint, it toggles whether the constraint binds to a margin or not. That's one convenient way to avoid re-editing the constraint. Further (and this is the hacky part because I can't explain it) I've noticed that in projects where I start holding option and binding AL constraints without the margin, that behavior becomes the default!

Like I said, it's hacky and I can't explain it why the default changes sometimes, but holding Option when you create constraints is the closest I've ever gotten.

erparker
  • 1,301
  • 10
  • 21
  • 2
    thanks man, I didn't know this and it will simplify my work a lot! – Sulthan Jun 15 '15 at 21:30
  • Ugh....why couldn't have just left the "Editor -> Pin" menu in XCode 7. This is so stupidly awkward. – Ross Barbish Sep 15 '15 at 18:17
  • Do you know how many hours this is going to save me! This isn't a hack if CTRL+Drag is your preferred way to create constraints anyway. I wish I could give this answer more upvotes – Korey Hinton Nov 19 '15 at 15:40
1

This plugin will set a default value of Constrain to margins to disabled.

https://github.com/mshibanami/DefaultMarginDisabler enter image description here

Gent
  • 6,215
  • 1
  • 37
  • 40
0

It is by default enabled in storyboards, I have not found how to disable it. But in Xibs, it is unchecked when you create a constraint. A solution may be to create a storyboard that instantiates your xibs, but you will loose every possibilities given by the segues.

So You may want to deal with it since there's no option for that (so far... ?).

Crazyrems
  • 2,551
  • 22
  • 40
  • 1
    Not always! For example, on a UIVIewCell xib, it will automatically be checked. On a UIViewController xib, it won't... WTF IB? – Martin Sep 02 '15 at 10:35