What does the origin control do in the interface builder?

In the designer of the interface, there is a control in the installer of arrangements and springs, which is marked as a source. What does this do and why does changing it for one object change it for ALL objects?

Origin control

As far as I can tell, this has no real effect on the start of the rectangle of the frame, as the name suggests. Let me explain:

Selecting UILabel and changing the origin in the upper right corner, as in the photo above, place the beginning of the frame at a point (280.11). However, in the code, when you really request a frame for its source, it is set as (211.11), which corresponds to the upper left corner of the frame. Therefore, changing the start of the frame in the interface builder seems to do absolutely nothing! What's going on here?!

+5
source share
2 answers

It does nothing if you do not edit the fields adjacent to it. You will notice that the X and Y coordinates change depending on the anchor point you choose; this means that it’s easier for you to align the object to its center or edge.

The reason that it changes for all objects is that it does not actually affect anything in the object itself; the "real" coordinate system remains unchanged regardless of the displayed values ​​of X and Y.

In OS X, as Nathan says, the coordinate system has a beginning in the lower left corner, and the coordinates are up and to the right; on iOS, the origin is in the upper left corner, and its coordinates increase to the bottom and right.

+7
source

, , , ( )

- (void) Button {

       CGRect frame = button.frame;
       frame.origin.x = 500; // new x coordinate
       frame.origin.y = 500; // new y coordinate
       button.frame = frame;
}

, , frame.origin , origin InterFace Builder

https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaDrawingGuide/Transforms/Transforms.html

Cocoa . . , .

- , - . , Cocoa , , . . , Cocoa , .

+3

All Articles