Search code examples
iphonecgrect

CGRectFrame, getting confused on origins


So I'm a bit confused when it comes to using the .frame property, CGRectMake, and the iPhone coordinate system.

I was looking at the code given in this example: Sizing a UILabel to fit?

I am confused on the line:

self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, fixedWidth, 0);

In the above line of code, is it basically setting self.frame to the same origin as it was originally, but changing the width and height?

The origin is the center point like in normal geometry right? It's not the upper left hand corner like the iPhone coordinate system is right? Thanks.


Solution

  • In the above line of code, is it basically setting self.frame to the same origin as it was originally, but changing the width and height?

    Yes.

    The origin is the center point like in normal geometry right? It's not the upper left hand corner like the iPhone coordinate system is right?

    No. frame.origin is a corner of the frame.

    See the documentation.