How to disable “Relative to margin” option for new

2019-03-17 06:09发布

问题:

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.

回答1:

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

https://github.com/mshibanami/DefaultMarginDisabler



回答2:

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:

Creating AL constraint while holding option:

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.



回答3:

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... ?).