2

In this question on the stackoveflow, he explains how different these three options are. But I am not clear of "Use current canvas value".

His explanation about this is Current canvas value copies the value from how you have the objects currently displayed on the canvas.

However, when I experimented on my xib file, there is no difference between manual entrance and this "Use current canvas value" option. I expected that I can get a certain value on a pin screen after entering the value by selecting this "Use current canvas value option". But again, nothing special happened. Could anyone explain?

Community
  • 1
  • 1
Kazuya Tomita
  • 667
  • 14
  • 34
  • "there is no difference" Because your settings are not "out of sync" with how the objects are displayed on the canvas. – matt May 05 '17 at 03:22

3 Answers3

3

You are not seeing any difference because in your situation there is no difference. If you want to see what using the canvas value does, you need to make a difference.

To do so, try this:

  • Add a view and pin it fully, like this button:

enter image description here

  • Now drag the button down and to the right.

Now we are out of sync! Your constraints say one thing, but your frame says another. Interface Builder reports this, and gives you a choice of what to do:

enter image description here

Now think about what the first two choices mean:

  • If you Update Frames, the button jumps back to where it was: the constraints win.

  • But if you Update Constraints, the button stays where it is — and the constraints values change to match its new position.

Well, Use Canvas Value is like Update Constraints:

enter image description here

In my screen shot, the constraint was 8, but we have moved the button so that the distance is actually 42. If we choose to Use Canvas Value, the button does not move, but the constraint value changes to 42.

matt
  • 515,959
  • 87
  • 875
  • 1,141
1

Use Current Canvas Value means use the values which matches what you have on screen in Interface Builder.

Annie Gupta
  • 2,786
  • 15
  • 23
0

Current canvas value specifies the constraint to be the distance from the respective edge of the object to the respective edge of its nearest neighbour. These are the default values you see when you open the Add New Constraints interface

enter image description here

In the canvas, canvas distance between label-top and view-top is 260, label-left and view-left is 207, etc. These values are the canvas value option.

Here's an example if you're still wondering: Create a new project, and add a label/button/etc to the screen. If you specify a value manually, say 42, and add the constraint. It will automatically move the element so the spacing in-between the two elements is 42 units.

If you now remove that constraint, and open the add new constraints interface, you will notice that where you previously pinned 42, it will show 42. The view has not moved since you manually set the distance to 42, so the canvas distance is 94 units.

Hayden Holligan
  • 1,822
  • 2
  • 19
  • 26