Grid layout with CollectionView in Swift

后端 未结 5 929
失恋的感觉
失恋的感觉 2021-01-30 14:04

I would like to achieve this result:

Searching around I found out that probably the way to do it is using UICollectionView, so no problem with that since t

5条回答
  •  梦如初夏
    2021-01-30 14:29

    I have created this meethod for custom layout. You can use by modifying according to your request.

    func setCollectionLayout() {
        let layout:UICollectionViewFlowLayout = UICollectionViewFlowLayout()
        layout.sectionInset = UIEdgeInsets(top:0,left:0,bottom:0,right:0)
        layout.itemSize = CGSize(width: UIScreen.main.bounds.size.width/2 - 1, height: 136)
        layout.minimumInteritemSpacing = 1
        layout.minimumLineSpacing = 1
        collectionView.collectionViewLayout = layout
    }
    

提交回复
热议问题