https://my.oschina.net/iq1990020

2016-11-23  本文已影响12人  seventhboy

2.使用方法

UICollectionView的使用方法和UITableView的基本相似,不同的是UICollectionViewFlowLayout和UICollectionViewCell

UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
[flowLayout setItemSize:CGSizeMake(CAPTURE_SIZE/2, CAPTURE_SIZE/2)];
[flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
flowLayout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
flowLayout.minimumLineSpacing = 10;
flowLayout.minimumInteritemSpacing = 0;
flowLayout.footerReferenceSize = CGSizeMake(300, 30);

_collectionView.delegate = self;
_collectionView.dataSource = self;
[_collectionView setCollectionViewLayout:flowLayout];
[_collectionView registerClass:[RDImgeCollectionCell class] forCellWithReuseIdentifier:@"RDImgeCollectionCell"];
[_collectionView setBackgroundColor:[UIColor whiteColor]];
UICollectionViewFlowLayout决定了UICollectionViewCell将要显示的大小,间隔,排列方式等

pragma -mark CollectionView DataSource

pragma -mark CollectionView UICollectionViewDelegate

用到UICollectionView的一个小项目Rando地址:http://git.oschina.net/jonear/Rando

上一篇 下一篇

猜你喜欢

热点阅读