我有一个UICollectionView
它包含自定义UICollectionViewCell
。收集视图具有背景图像。 我会显示背景图像,但集合视图(或其单元格)始终有一个白色背景,可防止显示背景图像。 下面是代码:背景色自定义uicollectionview
-(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。集合视图也使用非常基本的自定义布局。 一个什么在事先知情所示excertp:
集合视图显示细胞数。在收集视图下面有一个背景,因为单元格的颜色是白色而没有显示。 任何暗示赞赏。谢谢。
尝试使用[cell.backgroundView addSubView .. – iPatel
addSubView ...要添加什么? – giuseppe
UIImageView就可以了。 – iPatel