#define Start_X 15.0f // 第一个按钮的X坐标
#define Start_Y 50.0f // 第一个按钮的Y坐标
#define Width_Space 20.0f // 2个按钮之间的横间距
#define Height_Space 20.0f // 竖间距
#define Button_Height 40.0f // 高
#define Button_Width (([UIScreen mainScreen].bounds.size.width)-30-40)/3 // 宽
-(void)addButtonS
{
for (int i = 0 ; i < 6; i++) {
NSInteger index = i % 3;
NSInteger page = i / 3;
// 圆角按钮
UIButton *mapBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
mapBtn.tag = i;
mapBtn.frame = CGRectMake(index * (Button_Width + Width_Space) + Start_X, page * (Button_Height + Height_Space)+Start_Y, Button_Width, Button_Height);
mapBtn.backgroundColor = [UIColor redColor];
[self addSubview:mapBtn];
//按钮点击方法
[mapBtn addTarget:self action:@selector(mapBtnClick:) forControlEvents:UIControlEventTouchUpInside];
}
}