私はよく何をしたいが、何UICollectionView使用について理解している場合、私は知らない。
lazy var onBoardingCollectionView: UICollectionView = {
let layout = UICollectionViewFlowLayout()
layout.scrollDirection = .horizontal
layout.minimumLineSpacing = 0
layout.minimumInteritemSpacing = 0
let cv = UICollectionView(frame: self.view.frame, collectionViewLayout: layout)
cv.showsHorizontalScrollIndicator = false
cv.showsVerticalScrollIndicator = false
cv.isPagingEnabled = true
return cv
}()
をあなたは、画面の大きさだけでなくによってUICollectionViewDelegateFlowLayoutにおける方法であなたにカスタムセルを追加します。
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: SCREENW, height: SCREENH)
}
あなたはこの方法でデータソースとコレクションの前のものを表示し、削除する現在のセルを取得しようとすることができ、特定の方向に行くにしたくない場合。
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
let currentPage = Int(scrollView.contentOffset.x/scrollView.frame.width)
print("current cell: ", currentPage)
}