Placing a margin around each edge of the UICollectionView

后端 未结 7 1638
天涯浪人
天涯浪人 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:50

    Swift 4 updated (Vinayak Kini answer) :

    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
        return UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
    }
    

提交回复
热议问题