Poc*_*chi 16
如果这是用于iOS我认为你的功能是错误的.
CGRectGetMinY
返回建立矩形底边的y坐标.
CGFloat CGRectGetMinY(CGRect rect);
参数
矩形
Run Code Online (Sandbox Code Playgroud)The rectangle to examine.回报价值
指定矩形左下角的y坐标.可用性
Run Code Online (Sandbox Code Playgroud)Available in iOS 2.0 and later.相关示例代码
Run Code Online (Sandbox Code Playgroud)HeadsUpUI oalTouch PhotoScroller QuartzDemo SpeakHere在CGGeometry.h中声明
编辑:清除骚扰."CGRectGetMinY"是一个在CGRect上使用的函数,这意味着它将返回结果,就像它只考虑一个矩形一样.例如:
// 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));
Run Code Online (Sandbox Code Playgroud)
回报
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
Run Code Online (Sandbox Code Playgroud)
关键是要考虑这个,如果你要求最小值,你会得到一个比你要求最大值更低的值.即使您在不使用ios坐标系的情况下考虑这一点.
现在ios是倒置的,所以你必须考虑这个,前面的功能也会起作用,但从视觉上讲,结果是反转的,因为系统是倒置的.
// 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));
Run Code Online (Sandbox Code Playgroud)
回报
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
Run Code Online (Sandbox Code Playgroud)
对于看到这个的人来说,也没有错,min小于最大值.
因此,混淆在ios倒置系统中,因为您想要从倒置系统中检索视觉上较少的值.
这就是为什么它看起来很奇怪,CGGeometry中的描述是为"人类世界"而作出的.不适用于ios倒置系统.
| 归档时间: |
|
| 查看次数: |
10179 次 |
| 最近记录: |