【发布时间】:2019-09-27 16:27:32
【问题描述】:
我需要在我的第一列中实现偏移。我明白了,但是当我滚动到视图中时,最后一个单元格仍然移动到底部。每次滚动都会发生这种情况。
我的代码是下一个。
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let identifier = "Cell"
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath) as! cellFavoriteTransferCollectionViewCell
cell.titleName.text = "hola"
cell.hero.id = "Cell\(indexPath.row)"
if indexPath.row % 2 == 0 {
cell.frame = CGRect(x: cell.frame.origin.x, y: cell.frame.origin.y + 50, width: cell.frame.width, height: cell.frame.height)
} else {
cell.frame = CGRect(x: cell.frame.origin.x, y: cell.frame.origin.y, width: cell.frame.width, height: cell.frame.height)
}
return cell
}
我的错误是什么?由于最后一个单元格显示为一半,我必须如何更改垂直滚动大小?
【问题讨论】:
标签: ios swift uicollectionviewcell collectionview