[英]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.