这是一个漫长的一天,我的大脑似乎 不想和我合作了...
在一个子视图的数组中,通过每个视图的圈圈插入。每个子视图高度为 100 px。当数组有一个项时,视图的 Y 值需要设置为 0。当数组有两个项时, 索引 0 的视图需要设定为 y 值为 100, 索引 1 的项需要设定 Y 值为 0。 依此 :
1 item: 0 = 0
2 items: 0 = 100, 1 = 0
3 items: 0 = 200, 1 = 100, 2 = 0
4 items: 0 = 300, 1 = 200, 2 = 100, 3 = 0
我需要能够根据数组中的项目数量来动态地正确处理此事项。 以下是我到目前为止拥有的代码 :
for (int i = 0; i < [subViews count]; i++) {
NSView *v = (NSView *)[subViews objectAtIndex:i];
[v setFrameOrigin:NSMakePoint(copy.view.frame.origin.x, i * 100)];//This gives me the opposite of what I want...
}
谢谢!