zepojo / UPCarouselFlowLayout

A fancy carousel flow layout for UICollectionView on iOS.
MIT License
1.68k stars 236 forks source link

How to remove the initial space #36

Open milap-eww opened 6 years ago

milap-eww commented 6 years ago

simulator screen shot - iphone 8 plus - 2018-06-14 at 15 46 34

andre991 commented 6 years ago

Hi @milap-eww could you remove this space?

jpghelfi commented 6 years ago

Need the same!!

paskalem commented 6 years ago

The same??

Sent from my iPhone

On Nov 1, 2018, at 8:21 PM, jp notifications@github.com wrote:

Need the same!!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

jpghelfi commented 6 years ago

Yeap! I use a vertical flow, but the it's the same issue/request. I need to remove the initial spacing at the top of the collection. Any thoughts?

image

suraj-ios commented 5 years ago

@All,

let layout = UPCarouselFlowLayout() layout.itemSize = CGSize(width:UIScreen.main.bounds.size.width - 80, height:UIScreen.main.bounds.size.width - 80) layout.spacingMode = UPCarouselFlowLayoutSpacingMode.fixed(spacing: 10.0) self.collectionView.collectionViewLayout = layout self.rotationDidChange()

Remove space between two cell.

andre991 commented 5 years ago

@suraj-ios The problem is not this, the problem is that in the first cell it has a large space between the margin and the cell, when we scroll in the collection it returns to the expected state.

rudrankriyam commented 5 years ago

If anyone has been able to solve it, please help. Thanks!

rudrankriyam commented 5 years ago

For vertical spacing, I was able to solve it by adding this - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { return UIEdgeInsets(top: 2, left: 0, bottom: 0, right: 0) }

jonasz-baron commented 5 years ago

For me what helped was setting the itemSize after layout was properly defined, so in a view controller you could write in viewDidLayoutSubviews something like: layout.itemSize = CGSize(width: view.frame.width, height: someHeight) for horizontal scrolling.

JiteshBharadiya commented 5 years ago

@ALL

Try this, It worked for me

let indexPath = IndexPath(row: 2, section: 0) collectionView.selectItem(at: indexPath, animated: false, scrollPosition: .centeredHorizontally)

ahhhv commented 2 years ago

for me was change the edge inset left to my desired value in method updateLayout

sectionInset = UIEdgeInsets(top: yInset, left: 20, bottom: yInset, right: xInset)

hope it helps someone! cheers!