Can I move auto-detection restrictions in Interface Builder?

Sometimes autolayout constraints are bound to the wrong anchor point - for example, when I want control to become attached to control over it and the autolayout constraint anchors at the bottom of the window. Is there a way to move a constraint? The art of ASCII should make this clearer. This is what I have:

+------------------------+
|                        |
| [x] Some checkbox      |
|                        |
| [x] Another checkbox   |
|     |                  |
|     | ← autolayout     |
|     |   constraint     |
|     |                  |
+-----+------------------+

And that is exactly what I want:

+------------------------+
|                        |
| [x] Some checkbox      |
|     | ← A.C.           |
| [x] Another checkbox   |
|                        |
|                        |
|                        |
|                        |
+------------------------+

I can bind the constraint to the upper flag by moving the lower flag up, but this is not what I want, I want more vertical space. (The flags are for illustrative purposes only; my real use case has different ideas.)

+5
source share
3 answers
  • Select 2 checkboxes
  • "H"

enter image description here


:

enter image description here

+7

, . . "" .

+1

, . , , , , , . , , , ( ). :

2 , "" > "" > " ", ( 3- IB, ). . . Pin Align.

I found that getting the constraints you want is always possible, although this is a battle with the automatic constraints that Xcode adds, and sometimes a puzzle, to understand why they don't go from purple to blue. For example, moving the view directly after adding some user-defined constraint, and you will find that Xcode probably removed most of the constraints that you added, and again added automatic, even for other seemingly random views in the window, and not just that moved! Good luck.

+1
source

All Articles