title: UICollectionView - cell's background color on iOS 6
body: <p>I have a problem with setting background color for <code>UICollectionViewCell</code> and <code>UICollectionReusableView</code> objects. It's working without a problem on iOS 7, but on iOS 6 all I'm getting is white background.</p>
  
  <p>In my <code>UICollectionView</code>'s data source, I'm setting the background color in this method:</p>
  
  <pre><code>- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  </code></pre>
  
  <p>This code works for iOS 7 only:</p>
  
  <pre><code>cell.contentView.backgroundColor = [UIColor redColor];
  </code></pre>
  
  <p>This is what I've already tried to make it works on iOS 6:</p>
  
  <pre><code>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];
  </code></pre>
  
  <p>Unfortunately, without a success. I'm confused, and really don't know what I'm missing here.</p>
  
  <p>Apart of that issue, everything else is working as expected, my <code>UICollectionView</code> displays the cells correctly on iOS 7 as well as iOS 6.</p>
  
  <p>The code I am using is available on GitHub, as a part of library I've made. If you need more information about my implementation, check it here: <a href="https://github.com/darrarski/DRCollectionViewTableLayout-iOS" rel="nofollow">DRCollectionViewTableLayout-iOS</a>. The repository contains demo project with UICollectionView. On iOS 7 cells have random colors, on iOS 6 all cells have white backgrounds.</p>