Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ios UICollectionView separation on top / bottom between cells

I have a collection view, is working fine, and I have adjusted the separation for the X padding,

and it works fine, but for the Y padding between cells, doesn't seem to adjust to NO separation

This is my code for the layout

UICollectionViewFlowLayout *layoutItem=[[UICollectionViewFlowLayout alloc] init];
    layoutItem.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);

enter image description here So how can I set the separation on top / bottom to 0px? Between cells?,

thanks!

like image 428
manuelBetancurt Avatar asked Aug 03 '13 05:08

manuelBetancurt


People also ask

What is UICollectionView flow layout?

Overview. A flow layout is a type of collection view layout. Items in the collection view flow from one row or column (depending on the scrolling direction) to the next, with each row containing as many cells as will fit. Cells can be the same sizes or different sizes.

What is Section inset?

Section insets are margins applied only to the items in the section. They represent the distance between the header view and the first line of items and between the last line of items and the footer view. They also indicate the spacing on either side of a single line of items.

What is Minimumlinespacing?

The minimum spacing to use between lines of items in the grid.

What is Collectionviewlayout?

An abstract base class for generating layout information for a collection view.


1 Answers

you will see only top y padding at first time. And For showing bottom y padding you need more data that CollectionView frame height. When you scroll up collection view you will see bottom y padding.

I used collectionView like this

https://stackoverflow.com/a/17856406/1305001

When I set

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
    return UIEdgeInsetsMake(60, 10, 50, 10);
}

The output will come as First time..

enter image description here

When you scrolled up collectionView you will see bottom padding..

enter image description here

Use this for verticle line spacing between cells

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
    return 5;
}

Will look like

enter image description here

like image 50
Prince Kumar Sharma Avatar answered Sep 20 '22 17:09

Prince Kumar Sharma