If it is for iOS, I think your function is wrong.
http://developer.apple.com/library/ios/#documentation/GraphicsImaging/Reference/CGGeometry/Reference/reference.html
CGRectGetMinY
Returns the y coordinate that sets the bottom edge of the rectangle.
CGFloat CGRectGetMinY (CGRect rect);
Options
Rect
The rectangle to examine.
Return value
The y-coordinate of the lower left corner of the specified rectangle. Availability
Available in iOS 2.0 and later.
Sample code
HeadsUpUI oalTouch PhotoScroller QuartzDemo SpeakHere
Declared in CGGeometry.h
Edit : Remove Confucius. "CGRectGetMinY" is a function that will be used on CGRect, which means that it will return the result as if it were only looking at a rectangle. eg:
// With a self created element CGRect rect = CGRectMake(0, 429, 100, 44); NSLog(@"rect.origin.y: %f",rect.origin.y); NSLog(@"rect.size.height: %f",rect.size.height); NSLog(@"CGRectGetMinY(rect): %f",CGRectGetMinY(rect)); NSLog(@"CGRectGetMaxY(rect): %f",CGRectGetMaxY(rect));
returns
2012-06-04 10:55:49.737 test[7613:707] rect.origin.y: 429.000000 2012-06-04 10:55:49.739 test[7613:707] rect.size.height: 44.000000 2012-06-04 10:55:49.741 test[7613:707] CGRectGetMinY(rect): 429.000000 2012-06-04 10:55:49.748 test[7613:707] CGRectGetMaxY(rect): 473.000000
The key is to just think about it, if you ask for min, you will get a lower value than if you asked for max. Even if you think about it without using the ios coordinate system.
NOW ios IS is inverted, so you have to consider this, the previous function will work, but visually speaking, the result is inverted, because the system is inverted.
// With an element on the screen NSLog(@"gpsButton.frame.origin.y: %f",gpsButton.frame.origin.y); NSLog(@"gpsButton.frame.size.height: %f",gpsButton.frame.size.height); NSLog(@"CGRectGetMinY(gpsButton.frame): %f",CGRectGetMinY(gpsButton.frame)); NSLog(@"CGRectGetMaxY(gpsButton.frame): %f",CGRectGetMaxY(gpsButton.frame));
returns
2012-06-04 10:55:49.725 test[7613:707] gpsButton.frame.origin.y: 429.000000 2012-06-04 10:55:49.727 test[7613:707] gpsButton.frame.size.height: 44.000000 2012-06-04 10:55:49.732 test[7613:707] CGRectGetMinY(gpsButton.frame): 429.000000 2012-06-04 10:55:49.735 test[7613:707] CGRectGetMaxY(gpsButton.frame): 473.000000
For a person who sees this, there is nothing wrong, min less than max.
So the confusion is in the ios inverted system, since you want to get a visually lower value from the inverted system.
That's why it seems strange, the description in CGGeometry is made for the "human world". Not for ios inverted system.