UITableView
具有方法rectForRowAtIndexPath:
,但UICollectionView中不存在该方法.我正在寻找一种很好的方法来获取单元格的边框,也许我可以在UICollectionView
上添加一个类别.
UITableView
具有方法rectForRowAtIndexPath:
,但UICollectionView中不存在该方法.我正在寻找一种很好的方法来获取单元格的边框,也许我可以在UICollectionView
上添加一个类别.
我找到的最好的方法是这样做:
Objective-C
UICollectionViewLayoutAttributes *attributes = [self.collectionView layoutAttributesForItemAtIndexPath:indexPath];
Swift个
let attributes = collectionView.layoutAttributesForItem(at: indexPath)
然后您可以通过attributes.frame
或attributes.center
访问该位置