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"];
添加圖片到數(shù)組
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];
}
圖片的響應(yīng)事件
-(void)tap:(UITapGestureRecognizer *)tapGes
{
if (tapGes.view.tag ==0) {
}
if (tapGes.view.tag==3) {
}
if (tapGes.view.tag==4) {
}
if (tapGes.view.tag == 6)
{
}
}