//网格
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
[layout setScrollDirection:UICollectionViewScrollDirectionVertical];//滚动方向
layout.itemSize = CGSizeMake(KItemWidth, 165);
layout.headerReferenceSize = CGSizeMake(KviewWidth, 50);
layout.sectionInset = UIEdgeInsetsMake(20, 10, 50, 10);
layout.minimumInteritemSpacing = 1;
layout.minimumLineSpacing = 10;
layout.sectionHeadersPinToVisibleBounds = YES;//头部是否跟随移动
self.flowLayout = layout;
UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:layout];
[self.view addSubview:collectionView];
self.collectionView = collectionView;
collectionView.backgroundColor = [UIColor groupTableViewBackgroundColor];
[collectionView registerClass:[SZUploadCollectionViewCell class] forCellWithReuseIdentifier:@"SZ"];
[collectionView registerClass:[SZZeroCollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"header"];
collectionView.delegate = self;
collectionView.dataSource = self;
collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
[[self.mainViewModel.getListDataCommand execute:nil] subscribeNext:^(id x) {
[self reloadData];
// [self.collectionView reloadData];
}];
[self.collectionView.mj_header endRefreshing];
}];
网友评论