title: How to interpolate custom UICollectionViewLayoutAttributes properties with UICollectionViewTransitionLayout
body: <p>I have two custom <code>UICollectionViewLayout</code> objects that use a custom <code>UICollectionViewLayoutAttributes</code> subclass. These custom attributes add a single property <code>tintAlpha</code> that controls the opacity of a tint overlay view attached to each collection view cell.</p>
  
  <p>I now want to transition between these two layouts, using a <code>UICollectionViewTransitionLayout</code> subclass. How can I configure the transition layout subclass to interpolate the custom <code>tintAlpha</code> property on my custom layout attributes?</p>
  
  <p>I could do something like this:</p>
  
  <pre><code>- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath
  {
       CustomLayoutAttributes *attr = [super layoutAttributesForItemAtIndexPath:indexPath];
  
       CustomLayoutAttributes *fromAttr = (CustomLayoutAttributes *)[self.currentLayout layoutAttributesForItemAtIndexPath:indexPath];
       CustomLayoutAttributes *toAttr = (CustomLayoutAttributes *)[self.nextLayout layoutAttributesForItemAtIndexPath:indexPath];
  
       CGFloat t = self.transitionProgress;
       attr.tintAlpha = (1.0f - t) * fromAttr.tintAlpha + t * toAttr.tintAlpha;
  
       return attr;
  }
  </code></pre>
  
  <p>However this will ignore any changes applied to the attributes in <code>initialLayoutAttributesForAppearingItemAtIndexPath:</code> &amp; <code>finalLayoutAttributesForDisappearingItemAtIndexPath:</code> in the current or next layout, and so is not actually correct. As far as I can tell, the default implementation of <code>UICollectionViewTransitionLayout</code> determines the appropriate from/to attributes and caches them, either in <code>prepareLayout</code> or <code>layoutAttributesForItemAtIndexPath:</code>. It would be so useful to have some public API on <code>UICollectionViewTransitionLayout</code> to allow us to access these from/to attributes objects, as if I try and implement my own logic on whether to use the initial/final attributes vs the standard attributes there are bound to be some discrepencies from the default implementation.</p>
  
  <p>Is there a better way to interpolate these custom attributes during a layout transition?</p>
  
  <hr>
  
  <p><strong>Update:</strong></p>
  
  <p>I have just encountered an additional problem with this scenario. In the code above, when getting <code>fromAttr</code> &amp; <code>toAttr</code> directly from the current/next layouts, the <code>collectionView</code> is <code>nil</code> for the current layout (beyond the first run loop of the transition at least). If layout depends at all on the collection view's bounds - consider a simple cover flow layout for example - then the <code>fromAttr</code> will be incorrect.</p>
  
  <p>I'm really pining for a <code>interpolatedLayoutAttributesFromLayoutAttributes:toLayoutAttributes:progress:</code> on <code>UICollectionViewTransitionLayout</code> that can be overridden by subclasses.</p>