title: CATransform3D not being applied properly in custom UICollectionViewFlowLayout
body: <p>I'm having a strange issue with custom UICollectionViewFlowLayout, my cells contain an imageView, I apply a zoom effect to my cells... however I think that I'm doing something wrong with the Zoom Effect, it's strange, because my cells get scaled correctly, the problem is that the imageView for some cells is not.</p>
  
  <p>Here's the relevant code (I think) for this issue, (note that If I remove the method: <code>- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect</code> or the CATransform3DMakeScale, the problem doesn't seem to appear.)</p>
  
  <pre><code>///// UICollectionViewController.m
  
  
  - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  {
      HICollectionViewCell *cell = (HICollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:COLLECTION_VIEW_CELL_ID forIndexPath:indexPath];
      [self customizeCell:cell atIndexPath:indexPath];
      return cell;
  }
  
  #pragma mark - CollectionView FlowDelegate
  
  - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
  {
      return CGSizeMake(200.0f, 200.0f);
  }
  
  #pragma mark - "Private" Methods
  
  - (void)customizeCell:(HICollectionViewCell *)cell atIndexPath:(NSIndexPath *)indexPath
  {
      UIImageView *view = (UIImageView *)[cell.contentView viewWithTag:kCollectionViewCellSubViewTag_imgView];
      if (!view.image) {
          view.image = [UIImage imageNamed:@"placeholder.png"];
      }
  }
  </code></pre>
  
  <p>The Custom Layout Inherits from UICollectionViewFlowLayout</p>
  
  <pre><code>/////// CustomLayout.m
  
  static const CGFloat ACTIVE_DISTANCE = 200.0f;
  static const CGFloat ZOOM_FACTOR = 0.3f;
  
  - (id)init
  {
      if(self = [super init]) {
          self.itemSize = CGSizeMake(ITEM_SIZE, ITEM_SIZE);
          self.scrollDirection = UICollectionViewScrollDirectionHorizontal;
          self.sectionInset = UIEdgeInsetsMake(200.0f, 0.0f, 200.0f, 0.0f);
          self.minimumLineSpacing = 50.0f;
      }
  
      return self;
  }
  
  - (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds
  {
      return YES;
  }
  
  - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
  {
      NSArray *attributes = [super layoutAttributesForElementsInRect:rect];
      CGRect visibleRect;
      visibleRect.origin = self.collectionView.contentOffset;
      visibleRect.size = self.collectionView.bounds.size;
  
      for (UICollectionViewLayoutAttributes *attribute in attributes) {
          if (CGRectIntersectsRect(attribute.frame, rect)) {
              CGFloat distance = CGRectGetMidX(visibleRect) - attribute.center.x;
              CGFloat normalizedDistance = distance / ACTIVE_DISTANCE;
  
              // Apply a zoom factor to cells within ACTIVE_DISTANCE
              if (ABS(distance) &lt; ACTIVE_DISTANCE) {
                  CGFloat zoom = 1.0f + ZOOM_FACTOR * (1.0f - ABS(normalizedDistance));
                  attribute.transform3D = CATransform3DMakeScale(zoom, zoom, 1.0);
                  attribute.zIndex = round(zoom);
              }
          }
      }
  
      return attributes;
  }
  </code></pre>
  
  <p>As the FlowLayout appears everything looks fine.</p>
  
  <p><img src="https://i.stack.imgur.com/b1Gjn.png" alt="Img 1"></p>
  
  <p>Then I start to scroll and I notice that the background layer of the cells to the right starts to show off (<strong>backgroundColor is orange</strong>)</p>
  
  <p><img src="https://i.imgur.com/o5dllsS.png" alt="Img 2"></p>
  
  <p>As you can see, after two cells, the third one ( that starts to appear, looks OK again ).</p>
  
  <p><img src="https://i.imgur.com/IFL9dHb.png" alt="Img 3"></p>
  
  <p>Maybe it's an issue with the cell queue and dequeue (and the imageView being re-used or something?).</p>