0

enter image description here

This is the first cell, notice how the second cell is showing on right, what i want to achieve is, to keep my cell in centered while still showing parts left and right side cell when Paging is enabled.

// MARK: - CollectionView layout configuration
extension HomeVC: UICollectionViewDelegateFlowLayout {
    
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        
        return CGSize(width: collectionView.bounds.width - (indexPath.row == 0 || indexPath.row == list.count - 1 ? 50 : 40), height: collectionView.bounds.height)

    }
    
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
        return 10
    }
    
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
        return 10
    }
    
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
        if section == 0 {
            return UIEdgeInsets(top: 0, left: 30, bottom: 0, right: 30)
        } else {
            return UIEdgeInsets.zero
        }
    }
   
}
Rehan Ali Khan
  • 527
  • 10
  • 23
  • 1
    This is the same thing but using objective c https://stackoverflow.com/questions/13492037/targetcontentoffsetforproposedcontentoffsetwithscrollingvelocity-without-subcla/13493707#13493707 – Fogmeister Feb 27 '23 at 11:56

0 Answers0