Question: I know this is fairly easy for UITableViewCells but I'm not sure how to approach this using a UICollectionView.

EDIT. Pictures for clarification. Text content of the cells are not the same here but they should be.
In landscape:

![](https://i.stack.imgur.com/E4rB6.png)

In portrait:

![enter image description here](https://i.stack.imgur.com/M8yL6.png)

I tried to naively switch the color of my cell's text label with the cell's background color based on the index path's row property in the `cellForItemAtIndexPath:` method. However Index Path's row property isn't really a row in UICollectionViewFlowLayout.

Answer: 
I don' think there's any good general way to do this without subclassing the flow layout. For a more specific case, you can use integer math combined with the modulus operator to get "rows" from the indexPath. So, if you had 5 items on each row, you could return either 0 or 1 from this expression:

```
NSInteger rowTest = (indexPath.row / 5) % 2;

```

Just test this value, and change your color accordingly. Of course, you'll have to change the expression on rotation since you'll have a different number of items on each row.
This is yucky, subject to breaking if there's a header, but at least this will get you going. In cellForItemAtIndexPath...

```
// dequeue cell

CGFloat originY = cell.frame.origin.y;

// if there are headers, then grab the header view and...
originY -= header.bounds.size.height * indexPath.section;

NSInteger row = originY / cell.bounds.size.height;
BOOL evenRow = row%2 == 0;

```