UICollectionViewController的基本设置

1.实例化一个collectionView,并给其设置一个瀑布流,给cellectionView进行注册

注册的方法:

//    - (void)registerClass:forCellWithReuseIdentifier:

    //    - (void)registerClass:forSupplementaryViewOfKind:withReuseIdentifier:

    //    - (void)registerNib:forCellWithReuseIdentifier:

    //    - (void)registerNib:forSupplementaryViewOfKind:withReuseIdentifier:

2。设置代理数据源

3.读取cell的时候,从注册的cell中去取出

- (__kindof UICollectionViewCell *)dequeueReusableCellWithReuseIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath;

4.cell的设置

// xib得到的frame设置在这个awakeNib方法中

- (void)awakeFromNib

{

}

// 纯代码写的,其frame设置在这个方法中

- (instancetype)initWithFrame:(CGRect)frame

{

    self = [super initWithFrame:frame];

    if (self) {

        self.backgroundColor = [UIColor whiteColor];

    }

    return self;

}

 

风吹起的地方不是因为风动,是因为心动
原文地址:https://www.cnblogs.com/GLbog/p/5120878.html