title: layoutAttributesForElementsInRect: method trouble, how do I make my items in collection view fade from center?
body: <p>I have a <code>UICollectionView</code> with items. I want items in center be full color, and items closer to vertical borders of collection view to slowly fade.
  I came up with my custom implementation of <code>layoutAttributesForElementsInRect</code> but it doesn't seem to work as intended.</p>
  
  <p>First, it's getting rarely called. Once at startup and sometimes later, usually when I'm near <code>collectionView</code> end.
  Second, I fail to get normalized distance, it goes from -2 to 6, and I just want 0 to 1.</p>
  
  <p>What exactly am I failing here? I take the visible rect and calculate distance from cell center to its edges and then normalize it.</p>
  
  <pre><code>- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
  {
      NSArray *attribs = [super layoutAttributesForElementsInRect:rect];
  
      CGRect visibleRect;
      visibleRect.origin = self.collectionView.contentOffset;
      visibleRect.size = self.collectionView.bounds.size;
  
      for (UICollectionViewLayoutAttributes *attributes in attribs) {
          if (CGRectIntersectsRect(attributes.frame, rect)) {
  
              CGFloat distanceFromCenter = CGRectGetMidY(visibleRect) - attributes.center.y;
              CGFloat normalizedDistance = distanceFromCenter / (visibleRect.size.height / 2);
              attributes.alpha = 1 - normalizedDistance;
          }
      }
  
      return attribs;
  }
  </code></pre>
  
  <p>Update:</p>
  
  <p>Here is what I want:</p>
  
  <p><img src="https://i.stack.imgur.com/Rhl3S.png" alt="enter image description here"></p>
  
  <p>When the top line of dates (22-28) approaches the edge of collection view, I want them to slowly fade out. Same goes about the bottom row. As you can see dates 1 and 2 are already not visible since they were light grey color. Dates 1-31 are black because I highlight the month that occupies the majority of view now.   </p>
  
  <p>I do this via scroll view delegate method after each scroll now, but this is very ugly code.<br>
  I want to do the same in the layout attributes method.</p>