static NSString *identify = @"collectionViewCell";static NSString *identifier = @"Cell";
//UICollectionView flowLayout = [[UICollectionViewFlowLayout alloc]init]; [flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];//设置其布局方向 flowLayout.sectionInset = UIEdgeInsetsMake(5, 10, 5, 10);//设置其边界 //显示尾部视图的很重要的一行代码,不写:imp:呵呵flowLayout.footerReferenceSize = CGSizeMake(screenWidth, 105); _collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, imagView.bottom+10, screenWidth, screenHeight-64-21) collectionViewLayout:flowLayout]; _collectionView.dataSource = self; _collectionView.delegate = self; _collectionView.backgroundColor = [UIColor clearColor];//注册 [_collectionView registerClass:[MyCollectionViewCell class] forCellWithReuseIdentifier:identify]; [self.view addSubview:_collectionView]; //注册尾部视图 [_collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:_UICollectionElementKindSectionFooter_ withReuseIdentifier:identifier];
//创建视图方法-(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{ UICollectionReusableView *view = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:identifier forIndexPath:indexPath]; view.backgroundColor = [UIColor blueColor]; return view;}