NSArray *arr = @[@"mg_room_btn_liao_h",@"",@"",@"mg_room_btn_xinxi_h",@"mg_room_btn_liwu_h",@"mg_room_btn_fenxiang_h",@"mg_room_btn_guan_h"];
添加图片到数组
CGFloat x = 0;
初始位置
CGFloat kong = (widths-40*6)/10;
图片之间的空隙
for (int i = 0; i < 7; i++)
{
x = kong + (kong+40)*i;
// 图片
_imageView = [[UIImageView alloc] initWithFrame:CGRectMake(x, [UIScreen mainScreen].bounds.size.height-50, 40, 40)];
_imageView.tag = i;
_imageView.image = [UIImage imageNamed:arr[i]];
_imageView.userInteractionEnabled = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
[_imageView addGestureRecognizer:tap];
[self addSubview:_imageView];
}
图片的响应事件
-(void)tap:(UITapGestureRecognizer *)tapGes
{
if (tapGes.view.tag ==0) {
}
if (tapGes.view.tag==3) {
}
if (tapGes.view.tag==4) {
}
if (tapGes.view.tag == 6)
{
}
}