Reputation: 2890
Hi, I would like to make a design like this, I have a collectionView that has different sections, the first one has to be different... how can I do?
I have made different types of cells but it always has the same width as specified in the storyboard... Is there any way to set the width of the cell?
Thank you very much.
Upvotes: 2
Views: 1999
Reputation: 11123
You will need to adopt the UICollectionViewDelegateFlowLayout
protocol and implement the collectionView(_:layout:sizeForItemAtIndexPath:)
method. This method is implemented to specify the size of individual items to the UICollectionViewFlowLayout
object that does the layout in a collection view by default.
Here is a link to the relevant documentation.
Upvotes: 1
Reputation: 2586
You have to use UICollectionViewDelegateFlowLayout
, specifically this method:
- (CGSize)collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewLayout *)collectionViewLayout
sizeForItemAtIndexPath:(NSIndexPath *)indexPath
Just return there the size you want at the section or indexPath you need.
Upvotes: 3