Is it possible to translate a UICollectionViewCell's
coordinates from being relative to the UICollectionView
to being relative to the superview
? So far I've been unable to translate a UICollectionViewCell's
coordinates when touched to the superview
. Here's what I've tried so far:
- (void)collectionView:(UICollectionView *)collectionView
didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell =
[collectionView dequeueReusableCellWithReuseIdentifier:@"CollectionViewCell"
forIndexPath:indexPath];
CGRect frame = CGRectMake(0.0,
0.0,
cell.frame.size.width,
cell.frame.size.height);
frame.origin = [cell convertPoint:cell.frame.origin
toView:self.view];
}
I'd like to create a new frame which originates from the cell's position on the view, not in the UICollectionView
. Any help would be great thanks.
Just in case if anybody looking for this, here is how it can be done in Swift:
let cellFrameInSuperview = collectionView.convertRect(collectionView.cellForItemAtIndexPath(indexPath)!.frame, toView: view)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With