[英]IndexPath for first element in CollectionView
應該如何看看IndexPath在CollectionView中的第一個位置? 我需要將某個元素移動到第一個位置:
collectionView.moveItem(at: collectionView.indexPath(for: cell)!,
to: *????*))
使用IndexPath(item: Int, section: Int)
。 在這種情況下它將是
IndexPath(item: 0, section: 0)
你甚至可以將zero
靜態變量定義為CGRect
而其他人正在做
extension IndexPath {
static let zero = IndexPath(item: 0, section: 0)
}
並用它作為
collectionView.moveItem(at: collectionView.indexPath(for: cell)!, to: .zero))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.