0

I'm using this method below in my UICollectionView to stretch/fill the cell, but it seems like it's constraining to the margins. It's stopping like 10 px shy of the edges. I basically want to set the constraints of the cell to "0" and "0" to fill the width completely and NOT constrained to the margins.

    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout,
                    sizeForItemAt indexPath: IndexPath) -> CGSize {
    let customHeight = CGFloat(116)
    return CGSize(width: collectionView.frame.size.width, height: customHeight)
Cœur
  • 32,421
  • 21
  • 173
  • 232
thelegendary3
  • 83
  • 1
  • 7
  • Your UICollectionView is probably added in storyboard with constraints? If it is, you must make sure that your collection view has the correct frame https://stackoverflow.com/questions/25701979/xcode-6-beta-7-storyboard-adds-extra-space-on-right-and-left-sides –  Mar 21 '17 at 03:50
  • @sneak i'm using a UICollectionViewController so i can't adjust the constraints right? since i didnt just drag it in? Doesn't seem to fix it – thelegendary3 Mar 21 '17 at 04:00
  • Oh, then you can ignore my last comment and take a look at this instead: http://stackoverflow.com/questions/13970950/uicollectionview-spacing-margins implement the methods and return UIEdgeInsetsZero or Use storyboard as in the screenshots there –  Mar 21 '17 at 04:03
  • Is your `interitem` spacing 0? – Rikh Mar 21 '17 at 04:27
  • @Rikh i'm not sure, where would i access that? I'm using photos for the collection view, except it doesnt stretch across the screen and the photo gets cut off :[ – thelegendary3 Mar 21 '17 at 04:52

0 Answers0