1
目前我創建的UIButton的行(0,1,2,3)的新行水平創建UIButton的編程
int x=0;
for (int i=0; i<4; i++) {
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = CGRectMake(10+x,20, 100, 100);
x=x+120;
[btn.titleLabel setFont:[UIFont fontWithName:@"Helvetica-Bold" size:17.0]];
btn.tag=i;
NSString *str=[NSString stringWithFormat:@"%d",btn.tag];
[btn setTitle:str forState:UIControlStateNormal];
[btn setBackgroundColor:[UIColor redColor]];
[self.view addSubview:btn];
}
但同樣我想創建按鈕的另一行(4,5, 6,7)水平,但我找不到這樣做的邏輯。有誰能夠幫助我?