Change the layout of the contents for each cell in the CollectionView

Asked 1 years ago, Updated 1 years ago, 77 views

I would like to change the layout of each cell in CollectionView, but how can I do that?For example, if CollectionView implements three pages of paging processing, you want to place buttons and images in different layouts for each page.In this case, do I use a custom view?Or should I write in code within cellForItemAtIndexPath?
Please let me know if anyone knows.I'm sorry, but I appreciate your cooperation.

objective-c uicollectionview

2022-09-30 17:00

1 Answers

If you are using Storyboard,
Create several UICollectionViewCell layouts on the Storyboard and
You can name it in Identifier and specify it when cellForItemAtIndexPath is created.

NSString* cellIdentifier=@"Identifier of cell";
UICollectionViewCell*cell= [collectionView requestReusableCellWithReuseIdentifier: cellIdentifier forIndexPath:indexPath];


2022-09-30 17:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.