0 Replies - 704 Views - Last Post: 28 December 2016 - 08:51 AM

#1 jphoc13  Icon User is offline

  • D.I.C Addict

Reputation: 0
  • View blog
  • Posts: 584
  • Joined: 08-July 13

How to change background color in collection view cells?

Posted 28 December 2016 - 08:51 AM

I was easily able to do this in the array adapter of an android app, but my iOS app I am having trouble getting this to work.
public override UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath)
        {
            var cell = (CustomCollectionViewCell)collectionView.DequeueReusableCell(CustomCollectionViewCell.cellID, indexPath);
            if (indexPath.Row % 2 != 0)
            {
                
                cell.ContentView.BackgroundColor = UIColor.White;
                cell.BackgroundColor = cell.ContentView.BackgroundColor;
                
            }
            
            cell.UpdateCell(rows[indexPath.Row]);
            return cell;
        }


As you can see when my row number is an odd one it switches color to white for the cells. Right now they are all remaining gray.

This post has been edited by jphoc13: 28 December 2016 - 08:53 AM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1