#pragma mark - 网格视图
- (UICollectionView *)collections{
if (!_collections) {
_collections = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 230, self.view.frame.size.width, 300) collectionViewLayout:self.flow];
[_collections setDelegate:self];
[_collections setDataSource:self];
[_collections setBackgroundColor:[UIColor whiteColor]];
[_collections registerClass:[myCollectionViewCell class] forCellWithReuseIdentifier:@"myCell"];
}
return _collections;
}
- (UICollectionViewFlowLayout *)flow{
if (!_flow) {
_flow = [[UICollectionViewFlowLayout alloc]init];
[_flow setItemSize:CGSizeMake(80, 80)];
[_flow setMinimumLineSpacing:15];
[_flow setMinimumInteritemSpacing:10];
}
return _flow;
}
#pragma mark - 网格视图的 delegate datasour
- (NSInteger) numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return 12;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
myCollectionViewCell *mycell = [collectionView dequeueReusableCellWithReuseIdentifier:@"myCell" forIndexPath:indexPath];
//[mycell setBackgroundColor:[UIColor redColor]];
mycell.theimageview.image = [UIImage imageNamed:[NSString stringWithFormat:@"%ld",indexPath.item]];
mycell.thelable.text = [NSString stringWithFormat:@"%@",ziarray[indexPath.row]];
return mycell;
}