UICollectionView with different cell size

后端 未结 3 1129
感情败类
感情败类 2021-02-14 15:35

My goal is to create a UICollectionView with a layout as depicted below.

相关标签:
3条回答
  • 2021-02-14 15:41

    Use UICollectionViewDelegateFlowLayout method.

    func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
    
            let width : CGFloat
            let height : CGFloat
    
            if indexPath.item == 0 {
                width = 100
                height = 100
            } else {
                width = 50
                height = 50
            }
            return CGSizeMake(width, height)
    
    }
    
    0 讨论(0)
  • 2021-02-14 15:46

    many ways to do this below links.

    • https://stackoverflow.com/a/34654076/5054123
    • https://github.com/bryceredd/RFQuiltLayout
    • https://github.com/betzerra/MosaicLayout
    0 讨论(0)
  • 2021-02-14 16:01

    Without creating a custom layout of collection view it is not possible to achieve what you want.

    You can create custom cell size using its delegate method sizeforitematindexpath.

    Also, check this link which helps to create a custom layout.

    0 讨论(0)
提交回复
热议问题