How to get the rect of a UICollectionViewCell?

The best way I’ve found to do this is the following:

Objective-C

UICollectionViewLayoutAttributes *attributes = [self.collectionView layoutAttributesForItemAtIndexPath:indexPath];

Swift

let attributes = collectionView.layoutAttributesForItem(at: indexPath)

Then you can access the location through either attributes.frame or attributes.center

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)