UICollectionView Horizontal Paging not centered

前端 未结 11 1660
感动是毒
感动是毒 2020-12-02 09:32

I have a horizontal scrolling collectionView with each cell the size of the view. When I page through the collectionView it doesn\'t page by cell. The cells aren\'t in the c

11条回答
  •  眼角桃花
    2020-12-02 09:39

    Swift 3.0 set your own UICollectionViewFlowLayout

    let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
    let width = UIScreen.main.bounds.width
    layout.itemSize = CGSize(width: width, height: 154)
    layout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
    layout.minimumInteritemSpacing = 0
    layout.minimumLineSpacing = 0
    layout.scrollDirection = .horizontal
    collectionView?.collectionViewLayout = layout
    

提交回复
热议问题