//算法实例:
int margin = 30;//间隙
int width = 80;//格子的宽
int height = 80;//格子的高
for (int i = 0; i <9; i++) {
int row = i/3;
int col = i%3;
UILabel * label = [[UILabel alloc] init];
label.frame = CGRectMake(20+col*(width+margin), 40+row*(height+margin), width, height);
label.backgroundColor = [UIColor redColor];
[self.view addSubview:label];
}