//获取view在屏幕中的位置
UIWindow * Window =[[[UIApplication sharedApplication] delegate] window];
CGRect rect =[view convertRect:view.bounds toView:Window];
//获取网格cell在屏幕中的位置
//先获取需要获取位置的cell
UICollectionViewCell * cell = (UICollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
//cell在当前collection的位置
CGRect cellRect = [_collectionView convertRect:cell.frame toView:_collectionView];
//cell在当前屏幕的位置
CGRect rect2 = [_collectionView convertRect:cellRect toView:self.view];
网友评论