It takes only two lines of code to get the 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)
Shaik Riyaz May 11 '15 at 9:23 a.m. 2015-05-11 09:23
source share