How to Create This Layout in CollectionView

433 views Asked by At

Hi i'd like to know how do we implement this layout in collectionview od we need to put images or resize cells i followed this link https://www.raywenderlich.com/107439/uicollectionview-custom-layout-tutorial-pinterest but in this they are passing image size for item so is showing different size of items based on image size but i like to fix the layout some this like this in image enter image description here

Any help Would be Appreiciated

Thanks In Advance

1

There are 1 answers

2
Vishal Sonawane On

Use this awesome control to achieve your goal.

It is very simple to use.

Add Following Files to your project

customLayout.h
customLayout.m

Import customLayout in your controller where to use

#import "customLayout.h"

And use

<customLayoutDelegate> 

to your controller.

Write Simple Code in your viewDidLoad Method

 columncount=2; // How much Columns you required
    miniInteriorSpacing=10; // Minimum Spacing you required

    if(![collectionView.collectionViewLayout isKindOfClass:[customLayout class]]){
        customLayout *layout = [customLayout new];
        layout.delegate=self;
        layout.columnCount=columncount;

        collectionView.collectionViewLayout = layout;

        [collectionView reloadData];
    } 

For getting height of Label I have written a method.

-(float)calculateHeightForLbl:(NSString*)text width:(float)width;