Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable "Relative to margin" option for newly created constraint in Xcode6

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

like image 501
Ossir Avatar asked Sep 29 '14 05:09

Ossir


People also ask

What is constraint to margins in Xcode?

Feb 25, 2015 at 9:01. It is worth it to point out that when adding new constraints, newer versions of Xcode allow you to uncheck a box for "Constrain to Margins" that sets the same "Relative to Margins" flag. This is useful because it saves a few clicks!

How do I change constraints in Xcode?

Clicking the Edit button in any of the constraints brings up a popover where you can change the constraint's relationship, constant, priority, or multiplier. To make additional changes, double-click the constraint to select it and open it in the Attribute inspector.

How do I create a constraint in Xcode?

To create constraints select the button and click the Align icon in the auto layout menu. A popover menu will appear, check both “Horizontal in container” and “Vertically in container” options to center the button on the screen. Then click the “Add 2 Constraints” button. Run the application.


1 Answers

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.

like image 87
erparker Avatar answered Sep 19 '22 17:09

erparker