来自以下代码
// yPos = 0, width = 100, height = 150
[imagesMutable enumerateObjectsUsingBlock: ^(UIScrollView verticalScroll, NSUInteger idx, BOOL *stop){
[verticalScroll addSubView:[UIImageView setFrame:CGRectMake(0, yPos, width, height)]]
// some code
yPos += (height + 15)
}];
让我们说,如果imagesMutable得到3个对象。当我从某个地方读到CGRectMake正在使用笛卡尔坐标时(x = 0,y = 0将在左下角)。所以,它应该是
[verticalScroll addSubView:[UIImageView setFrame:CGRectMake(0, 0, 100, 150)]]
[verticalScroll addSubView:[UIImageView setFrame:CGRectMake(0, 165, 100, 150)]]
[verticalScroll addSubView:[UIImageView setFrame:CGRectMake(0, 330, 100, 150)]]
这应该意味着
First CGRectMake should has bottom left at (0, 0) and top right at (100, 150)
Second CGRectMake should has bottom left at (0, 165) and top right at (100, 315)
Third CGRectMake should has bottom left at (0, 330) and top right at (100, 480)
然后,从上到下的图像顺序应为3 - > 2 - > 1与imagesMutable的对象排序(1 - > 2 - > 3)
相比较但为什么,它按照1 - >的顺序出现? 2 - > 3与我启动应用程序时的imagesMutable对象排序相同?我错过了什么吗?
答案 0 :(得分:33)
(0,0)不是左下角,而是左上角。
视图的y坐标反转,因此当您向下移动屏幕时y会增加。