In interface builder there is a control in the struts and springs inspector that is labeled origin. What does this do and why does changing it for one object change it for ALL objects?
As far as I can tell it doesn't have any real effect on the frame rectangle origin as the name implies. Let me explain:
Selecting a UILabel and changing the origin to be at the top right as in the photo above puts the frame origin at the point (280,11). However, in code, when you actually ask the frame for it's origin it is given as (211,11) which corresponds to the top left corner of the frame. Therefore, changing the frame origin in interface builder appears to do absolutely nothing! What is going on here?!
Interface Builder is a software development application for Apple's macOS operating system. It is part of Xcode (formerly Project Builder), the Apple Developer developer's toolset. Interface Builder allows Cocoa and Carbon developers to create interfaces for applications using a graphical user interface.
Creating the interface First, in Xcode, go to the Resources folder from the tree view on the left and select MainMenu. xib . It will open in the main view. This is where you are going to build you UI.
It does nothing unless you’re editing the fields immediately adjacent to it. You’ll note that the X and Y coordinates change depending on the anchor point you select for it; that’s meant to make it easier for you to align the object by its center or edge.
The reason it changes for all objects is that it doesn’t actually affect anything about the object itself; the “real” coordinate system remains the same regardless of the displayed X and Y values there.
On OS X, as Nathan says, the coordinate system has its origin at the bottom left and its coordinates increase up and to the right; on iOS, the origin is at the top left, and its coordinates increase to the bottom and right.
i don't now the exact answer but i think that it has to do with the origin code you've set for that object like (just a example)
- (void) Button {
CGRect frame = button.frame;
frame.origin.x = 500; // new x coordinate
frame.origin.y = 500; // new y coordinate
button.frame = frame;
}
And maybe there is a way to set the frame.origin
to a setting that would connect it to the origin tool in InterFace Builder
https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaDrawingGuide/Transforms/Transforms.html
Cocoa uses a Cartesian coordinate system as its basic model for specifying coordinates. The origin in this system is located in the lower-left corner of the current drawing space, with positive values extending along the axes up and to the right of the origin point. The root origin for the entire system is located in the lower-left corner of the screen containing the menu bar.
If you were forced to draw all your content in screen coordinates—the coordinate system whose origin is located at the lower-left corner of the computer’s primary screen—your code would be quite complex. To simplify things, Cocoa sets up a local coordinate system whose origin is equal to the origin of the window or view that is about to draw. Subsequent drawing calls inside the window or view take place relative to this local coordinate system. Once the code finishes drawing, Cocoa and the underlying graphics system convert coordinates in the local coordinates back to screen coordinates so that the content can be composited with content from other applications and sent to the graphics hardware.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With