用UICellectionView也可以搞定概龄,根據(jù)需求來選擇吧:)
在一個(gè)view中根據(jù)imgArray中圖片數(shù)量,動(dòng)態(tài)創(chuàng)建多個(gè)UIImageView展示圖片饲握,一行展示三個(gè)圖片私杜,當(dāng)多于三個(gè)時(shí),圖片多一行救欧,整個(gè)view也要增加高度衰粹。
//取屏幕寬高
floatwidth = [UIScreen mainScreen].bounds.size.width;
chooseImageView = [[UIViewalloc] init];NSArray*imgArray = [[NSArrayalloc] initWithObjects:@"1_leirobin.jpg",@"1_leirobin.jpg",@"1_leirobin.jpg",@"1_leirobin.jpg",@"1_leirobin.jpg",nil];NSIntegerpicCount = [imgArray count];//定義每個(gè)cell圖片for(inti=0;i
imageCell.image= [UIImageimageNamed:[NSStringstringWithFormat:@"%@",[imgArray objectAtIndex:i]]];//每當(dāng)?shù)?個(gè)圖片時(shí),增加一行笆怠,增加整個(gè)view的高度if(i%3==0) {
[chooseImageView setFrame:CGRectMake(0,100, width, chooseImageView.frame.size.height+width/3+20)];
}
[chooseImageView addSubview:imageCell];
}
[self.viewaddSubview:chooseImageView];