How to disable “Relative to margin” option for new

2019-03-17 05:18发布

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

3条回答
等我变得足够好
2楼-- · 2019-03-17 05:57

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.

查看更多
走好不送
3楼-- · 2019-03-17 06:00

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

查看更多
姐就是有狂的资本
4楼-- · 2019-03-17 06:17

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

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

查看更多
登录 后发表回答