static NSString * const HeadCellID = @"UIcollectionHeadCell";
static NSString * const MeTitleCellID = @"MeTitleCell";
static NSString * const MeTopBottomCellID = @"MeTopBottomCell";
static NSString * const ImgHeaderCellID = @"ImgHeaderCell";
static NSString * const NilCellID = @"NilCell";
// flowLayout.minimumInteritemSpacing = 5;
// flowLayout.minimumLineSpacing = 8;
// flowLayout.headerReferenceSize = CGSizeMake(0, 10);
// flowLayout.sectionInset = UIEdgeInsetsMake(0, 10, 0, 10);
// flowLayout.itemSize =CGSizeMake((Kwidth - 10 * 2) * 0.5 - 4, 250);
// flowLayout.headerReferenceSize = CGSizeMake(Kwidth, Kwidth*0.31+ 5 + 80 );//头部
// flowLayout.footerReferenceSize = CGSizeMake(Kwidth, 60 );//尾部
- (instancetype)init{
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
self = [self initWithCollectionViewLayout:flowLayout];
if (self) {
// insert code here...
}
return self;
}
-(void)viewDidLoad {
[super viewDidLoad];
self.collectionView.backgroundColor = BaseBgWhiteColor;
// //Nib注册头部
// [self.collectionView registerNib:[UINib nibWithNibName:NSStringFromClass([UIcollectionHeadCell class]) bundle:[NSBundle mainBundle]] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:HeadCellID];
//代码注册头部
[self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:ImgHeaderCellID];
[self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:NilCellID];
//Nib注册cell
[self.collectionView registerNib:[UINib nibWithNibName:NSStringFromClass([UIcollectionHeadCell class]) bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:HeadCellID];
[self.collectionView registerNib:[UINib nibWithNibName:NSStringFromClass([MeTopBottomCell class]) bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:MeTopBottomCellID];
[self.collectionView registerNib:[UINib nibWithNibName:NSStringFromClass([MeLeftRightCell class]) bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:MeLeftRightCellID];
[self.collectionView registerNib:[UINib nibWithNibName:NSStringFromClass([MeTitleCell class]) bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:MeTitleCellID];
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
// 这句话的意思是为了 不管集合视图里面的值 多不多 都可以滚动 解决了值少了 集合视图不能滚动的问题
self.collectionView.alwaysBounceVertical = YES;
//隐藏滚动条
self.collectionView.showsVerticalScrollIndicator = NO;
//设置上左下右距离
self.collectionView.contentInset = UIEdgeInsetsMake( -64, 0, 0,0);
[self setNav];
}
MeTopBottomCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:MeTopBottomCellID forIndexPath:indexPath];
MeitemModel *data = self.person_ModelArr[indexPath.row-1];
cell.textLabel.text = data.text;
cell.imgView.image =[UIImage imageNamed:data.img];
cell.backgroundColor = [UIColor whiteColor];
return cell;