UICollectionViewCell
및 UICollectionReusableView
개체의 배경색 설정에 문제가 있습니다. iOS 7에서는 문제없이 작동하지만 iOS 6에서는 모두 흰색 배경입니다. 내 UICollectionView
에서UICollectionView - iOS 6의 셀 배경색
의 데이터 소스,이 방법의 배경 색상을 설정하고 있습니다 :
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
이 코드는 아이폰 OS 7에서만 작동 :
cell.contentView.backgroundColor = [UIColor redColor];
이 내가 무엇인가 ' 이미 iOS 6에서 작동하도록 만들었습니다.
UIColor *backgroundColor = [UIColor redColor];
cell.backgroundColor = backgroundColor;
cell.backgroundView = [[UIView alloc] initWithFrame:cell.bounds];
cell.backgroundView.backgroundColor = backgroundColor;
cell.layer.backgroundColor = [backgroundColor CGColor];
cell.backgroundView.layer.backgroundColor = [backgroundColor CGColor];
cell.contentView.layer.backgroundColor = [backgroundColor CGColor];
불행히도, 성공하지 못했습니다. 나는 혼란스럽고 정말로 내가 여기에서 놓친 것을 모른다. 다른 그 문제 외에도
, 모든 라이브러리의 일환으로, 아이폰 OS 7뿐만 아니라 아이폰 OS 6내가 사용하고 코드는 GitHub에 볼 수 있습니다에서 제대로 내 UICollectionView
표시 세포, 예상대로 작동 나는 만들었다. 구현에 대한 추가 정보가 필요하면 여기에서 확인하십시오 : DRCollectionViewTableLayout-iOS. 리포지토리에는 UICollectionView가 포함 된 데모 프로젝트가 포함되어 있습니다. iOS 7 셀에는 임의의 색상이, iOS 6에는 모든 셀에 흰색 배경이 있습니다.
필자가 아는 한 'cell.backgroundColor = [UIColor redColor];와 정확히 동일하지만 시도해 볼 것입니다. – Darrarski
Nope. 이것은 iOS 6에서 여전히 흰색 배경으로 변경되지 않습니다. – Darrarski
내 대답이 업데이트되었습니다. 도움이 되었기를 바랍니다. – kchromik