網(wǎng)格視圖

#pragma mark - 網(wǎng)格視圖

- (UICollectionView *)collections{

if (!_collections) {

_collections = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 230, self.view.frame.size.width, 300) collectionViewLayout:self.flow];

[_collections setDelegate:self];

[_collections setDataSource:self];

[_collections setBackgroundColor:[UIColor whiteColor]];

[_collections registerClass:[myCollectionViewCell class] forCellWithReuseIdentifier:@"myCell"];

}

return _collections;

}

- (UICollectionViewFlowLayout *)flow{

if (!_flow) {

_flow = [[UICollectionViewFlowLayout alloc]init];

[_flow setItemSize:CGSizeMake(80, 80)];

[_flow setMinimumLineSpacing:15];

[_flow setMinimumInteritemSpacing:10];

}

return _flow;

}

#pragma mark - 網(wǎng)格視圖的 delegate datasour

- (NSInteger) numberOfSectionsInCollectionView:(UICollectionView *)collectionView{

return 1;

}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{

return 12;

}

- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{

myCollectionViewCell *mycell = [collectionView dequeueReusableCellWithReuseIdentifier:@"myCell" forIndexPath:indexPath];

//[mycell setBackgroundColor:[UIColor redColor]];

mycell.theimageview.image = [UIImage imageNamed:[NSString stringWithFormat:@"%ld",indexPath.item]];

mycell.thelable.text = [NSString stringWithFormat:@"%@",ziarray[indexPath.row]];

return mycell;

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容