2013-09-27 5 views
3

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 모든 배경 이미지를 설정합니다. 또한 콜렉션 뷰는 매우 기본적인 사용자 정의 레이아웃을 사용합니다. 은 PIC에 표시되는 내용의 excertp : 번호

enter image description here

컬렉션보기 쇼 세포. 컬렉션보기 아래에는 셀의 흰색 색상 때문에 배경이 표시되지 않습니다. 힌트를 보내 주시면 감사하겠습니다. 고맙습니다.

+0

[cell.backgroundView addSubView .. 시도해보십시오. – iPatel

+0

addSubView ... 추가 할 내용은 무엇입니까 ?? – giuseppe

+0

그것에 UIImageView. – iPatel

답변

0

솔브. 문제는 사용자 지정 셀 렌더링에있었습니다. 셀의 배경색을 설정하는 방법 (분실 된 방법 ...)을 사용했습니다. 비 - 사용자 정의 셀 들어, 내 질문에 코드가 맞습니다.

-1

UICollectionView의 backgroundview를 설정하여 사용자 지정 UICollectionView의 배경색을 지정할 수도 있습니다. UIView * blueView = [[UIView alloc] init]; blueView.backgroundColor = [UIColor blueColor]; self.collectionView.backgroundView = blueView;