我有一个UICollectionView
包含custom的UICollectionViewCell
。集合视图具有背景图像。我将显示背景图像,但是集合视图(或其单元格)始终具有白色背景,从而无法显示我的背景图像。这是代码:
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
AgendaCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:agendaCellIdentifier forIndexPath:indexPath];
cell.delegate = self;
cell.layer.borderWidth=0.0f;
cell.layer.backgroundColor = [UIColor clearColor].CGColor;
cell.contentView.layer.backgroundColor = [UIColor blackColor].CGColor;
cell.layer.shouldRasterize = YES;
cell.layer.rasterizationScale = [UIScreen mainScreen].scale;
[cell setCurrentDateAtIndex:([indexPath row]) date:currentMonth events:events];
return cell;
}
这AgendaCollectionCell
非常简单:我使用IB制作了一个单元,并将所有背景图像设置为clearColor。集合视图也使用非常基本的自定义布局。图片中的摘录:
集合视图显示带有数字的单元格。在收集视图下面有一个背景,由于单元格是白色,所以没有显示。任何提示表示赞赏。谢谢。
解决了。问题出在自定义单元格的呈现中。我使用了一种方法(丢失的方法...)来设置单元格的背景色。对于非自定义单元格,我的问题中的代码是正确的。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句