I’ve created a set view with compositional structure, Beneath is the code I’ve used for creating the structure.
func getCompositionalLayout() -> UICollectionViewCompositionalLayout {
let merchandise = NSCollectionLayoutItem(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .fractionalHeight(1/3)))
merchandise.contentInsets = NSDirectionalEdgeInsets(high: 1, main: 1, backside: 1, trailing: 1)
//--------- Group 1 ---------//
let group1Item1 = NSCollectionLayoutItem(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1/2), heightDimension: .fractionalHeight(1)))
group1Item1.contentInsets = NSDirectionalEdgeInsets(high: 1, main: 1, backside: 1, trailing: 1)
let nestedGroup1Item1 = NSCollectionLayoutItem(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .fractionalHeight(1/2)))
nestedGroup1Item1.contentInsets = NSDirectionalEdgeInsets(high: 1, main: 1, backside: 1, trailing: 1)
let nestedGroup2Item1 = NSCollectionLayoutItem(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1/2), heightDimension: .fractionalHeight(1)))
nestedGroup2Item1.contentInsets = NSDirectionalEdgeInsets(high: 1, main: 1, backside: 1, trailing: 1)
let nestedGroup2 = NSCollectionLayoutGroup.horizontal(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .fractionalHeight(1/2)), subitems: [nestedGroup2Item1])
let nestedGroup1 = NSCollectionLayoutGroup.vertical(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1/2), heightDimension: .fractionalHeight(1)), subitems: [nestedGroup1Item1, nestedGroup2])
let group1 = NSCollectionLayoutGroup.horizontal(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .fractionalHeight(1/3)), subitems: [group1Item1, nestedGroup1])
//--------- Group 2 ---------//
let group2Item1 = NSCollectionLayoutItem(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1/3), heightDimension: .fractionalHeight(1)))
group2Item1.contentInsets = NSDirectionalEdgeInsets(high: 1, main: 1, backside: 1, trailing: 1)
let group2 = NSCollectionLayoutGroup.horizontal(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .fractionalHeight(1/3)), subitems: [group2Item1])
//--------- Container Group ---------//
let containerGroup = NSCollectionLayoutGroup.vertical(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .absolute(600)), subitems: [item, group1, group2])
let part = NSCollectionLayoutSection(group: containerGroup)
let structure = UICollectionViewCompositionalLayout(part: part)
return structure
}
with this block of code my assortment view appear to be this
enter picture description right here
Now my query is how do I do know the RED CELL each time it happens in cellForItem methodology in order that I can present the completely different content material in it. (similar like Instagram reveals the video in bigger cell on their search web page).
Am unable to determine the crimson cell (Its in Group 1 with identify group1Item1)