Search code examples
ioscgrect

Getting the data from a CGRect object


I know that a CGRect consists of 4 floats. How can I get those floats from a given CGRect object?

I searched for CGRect's class reference and found nothing.


Solution

  • Like this: (assuming a previously defined CGRect called myRect)

    CGFloat x = myRect.origin.x;
    CGFloat y = myRect.origin.y;
    CGFloat height = myRect.size.height;
    CGFloat width = myRect.size.width;