Posts

Post not yet marked as solved
0 Replies
1.2k Views
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.1Image for ref: https://ibb.co/1QgBVbNclass 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) } }
Posted
by knowbiea.
Last updated
.