【发布时间】:2015-05-06 00:04:21
【问题描述】:
我有一个方法:
-(void) generateButtons {
int positionsLeftInRow = BUTTONS_PER_ROW;
int j = 0;
for (int i = 0; i < [self.Model.buttons count]; i++) {
NSInteger value = ((Model *)self.Model.buttons[i]).value;
ButtonView *cv = [[ButtonView alloc] initWithFrame:CGRectMake((i % BUTTONS_PER_ROW) * 121 + (i % BUTTONS_PER_ROW) * 40 + 205, j * 122 + j * 40 + 320, 125, 125) andPosition:i andValue:value];
if (!((Model *)self.Model.buttons[i]).outOfPlay) {
[self.boardView addSubview:cv];
if ([self.Model.usedButtons containsObject: self.Model.buttons[i]]) {
[self.usedButtons addObject: cv];
[cv flip];
}
}
if (--positionsLeftInRow == 0) {
j++;
positionsLeftInRow = BUTTONS_PER_ROW;
}
}
}
所以,我的问题是,如何为每一行进行水平位移,例如第二行从第一行和第三行移位。
编辑:
我的按钮视图现在看起来像这样:(简单)
* * * * *
* * * * *
* * * * *
* * * * *
但在某些视图中,我希望它们像这样放置:
* * * * *
* * * * *
* * * * *
* * * * *
我希望这是可以理解的......
编辑2:
现在可以了!
但是我怎样才能用我的 cgrectmake 制作这样的东西:
*
* *
* * *
编辑3:
如果我想做这样的事情:
* * * * * *
* * * * *
* * * * * *
* * * * *
它使这个:
* * * * *
* * * * * *
* * * * *
不知道为什么……
【问题讨论】:
-
你能粗略地描述一下你希望这些的外观并将其添加到问题中吗?您还应该在您的问题中向我们提供更多详细信息,因为很难确切知道您想要什么。你想要线条还是盒子?什么是 ButtonView?
标签: ios objective-c cgrectmake