0 Replies
      Latest reply on Nov 28, 2019 3:36 AM by knowbiea
      knowbiea Level 1 Level 1 (0 points)

        Hello,

         

        I have been working on Demo Collection View, I have added 10 rows in horizontal with pagination, In the last row of CollectionView, it shows the extra white space in the Simulator. my Xcode is 11.2.1

        Image for ref: https://ibb.co/1QgBVbN

         

        class ViewController: UIViewController {
            
            @IBOutlet weak var collectionView: UICollectionView!
            override func viewDidLoad() {
                super.viewDidLoad()
                collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "Cell")
            }
        }
        
        //MARK: - UICollectionView Delegates
        extension ViewController: UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
            func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
                return 10
            }
            
            func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
                let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath)
                cell.backgroundColor = UIColor(red: CGFloat(arc4random_uniform(255)) / 255.0, green: 15/255.0, blue: 25/255.0, alpha: 1.0)
                
                return cell
            }
            
            func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
                return CGSize(width: collectionView.frame.size.width, height: collectionView.frame.size.height)
            }
        }