您好,欢迎来到二三四教育网。
搜索
您的当前位置:首页UICollectionView的创建

UICollectionView的创建

来源:二三四教育网
//网格

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];
}];

Copyright © 2019- how234.cn 版权所有 赣ICP备2023008801号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务