for (int i = 0; i < 6; i ++) {
int n = 20 + i % 3 * 90 + i % 3 * 20;
int m = 10 + i / 3 * 90 + i / 3 * 20;
UIButton * bun = [UIButton buttonWithType:UIButtonTypeCustom];
bun.frame = CGRectMake(n, m, 60, 60);
[bun setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@",[你的数组名字 objectAtIndex:i]]] forState:UIControlStateNormal];
bun.tag = i + 1000;
[bun addTarget:self action:@selector(buttonSix:) forControlEvents:UIControlEventTouchUpInside];
[aView addSubview:bun];
}
这是设置出来显示的是2行3列的九宫格。