ios UICollectionView separation on top / bottom between cells

后端 未结 2 1956
傲寒
傲寒 2021-02-05 14:28

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

2条回答
  •  独厮守ぢ
    2021-02-05 14:55

    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

提交回复
热议问题