-1

This is sample of my data from api:

{
    "seats": [
        {
            "column": 0,
            "row": 0
        },
        {
            "column": 2,
            "row": 3
        },
        {
            "column": 1,
            "row": 2
        },
        {
            "column": 0,
            "row": 1
        }
    ]
}

My CollectionView screenshot: default collectionView

My question, how to insert sample data above into specific column and row cell based on that sample data column and row? I want to make my collectionview like following image based on that data: inserted items/data collectionView

Please help me..

hudadev
  • 59
  • 5
  • Parse your JSON using model and use in Collection view. Please refer to this https://stackoverflow.com/questions/48670189/creating-decoration-view-as-custom-column-in-uicollection-view – Sailendra Dec 23 '19 at 03:14
  • 1
    Related: https://stackoverflow.com/questions/15572462/how-to-insert-cell-in-uicollectionview-programmatically – twodayslate Dec 23 '19 at 03:16

1 Answers1

0

Parse your data as array of IndexPath.

var apiData: [IndexPath] = []

In collectionView's dataSource, cellForItem(at: IndexPath), use the following code:

if apiData.contains(indexPath) {
  cell.alpha = 1.0
}
else {
  cell.alpha = 0.0
}
udbhateja
  • 948
  • 6
  • 21