Ios 如何获取UICollectionView的rect
我想在UICollectionView中找到节标题的框架。对于UITableView,我有一个类似的情况,为此,我可以通过执行以下操作来获得它的rect:Ios 如何获取UICollectionView的rect,ios,objective-c,uicollectionviewlayout,cgrect,Ios,Objective C,Uicollectionviewlayout,Cgrect,我想在UICollectionView中找到节标题的框架。对于UITableView,我有一个类似的情况,为此,我可以通过执行以下操作来获得它的rect: CGRect rect = [self.tableView rectForHeaderInSection:section]; 有没有办法在UICollectionView中获得相同的结果?谢谢 对不起,伙计们。其实很简单 NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 i
CGRect rect = [self.tableView rectForHeaderInSection:section];
有没有办法在UICollectionView中获得相同的结果?谢谢 对不起,伙计们。其实很简单
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:section];
UICollectionViewLayoutAttributes *attributes = [self.collectionView layoutAttributesForSupplementaryElementOfKind:UICollectionElementKindSectionHeader atIndexPath:indexPath];
CGRect rect = [attributes frame];