Placing a margin around each edge of the UICollectionView

后端 未结 7 1659
天涯浪人
天涯浪人 2020-12-14 18:18

When the UICollectionView is populated with items they always go right to the edges of the UICollectionView like so:

---------------
|X X X X X X X|
|X X X X         


        
7条回答
  •  一个人的身影
    2020-12-14 18:47

    In

    (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    }
    

    you can give your cells some margin on the left side.

    Or you can create custom cells, which have a margin.

    or you can set the property .sectionInset of your CollectionviewFlowLayout, which should be the easiest way (if you use FlowLayout)

提交回复
热议问题