UITableView
has the method rectForRowAtIndexPath:
, but this does not exist in UICollectionView. I\'m looking for a nice clean way to grab a cell\'s
Only two lines of code is required to get perfect frame :
Objective-C
UICollectionViewLayoutAttributes * theAttributes = [collectionView layoutAttributesForItemAtIndexPath:indexPath];
CGRect cellFrameInSuperview = [collectionView convertRect:theAttributes.frame toView:[collectionView superview]];
Swift 4.2
let theAttributes = collectionView.layoutAttributesForItem(at: indexPath)
let cellFrameInSuperview = collectionView.convert(theAttributes.frame, to: collectionView.superview)