Simple layout, simple to use, the effect is as follows
First, be sure to determine the size of each cell, and the spacing between the cells, the distance between the margins, and
#pragmaMark--uicollectionviewdelegateflowlayout//define the size of each item-(Cgsize) CollectionView: (Uicollectionview *) CollectionView layout: (uicollectionviewlayout*) collectionviewlayout Sizeforitematindexpath: (Nsindexpath *) indexpath{//kdeceive_width for [UIScreen mainscreen].bounds.size.width,12 is margin, spacing, and Colletioncell columnsCGFloat height= (kdeceive_width- A)/Colletioncell; returnCgsizemake (height, height);//Set cell width height}//define margin for each Uicollectionview-(Uiedgeinsets) CollectionView: (Uicollectionview *) CollectionView layout: (Uicollectionviewlayout *) collectionviewlayout Insetforsectionatindex: (nsinteger) section{returnUiedgeinsetsmake (4,4,4,4);}-(CGFloat) CollectionView: (Uicollectionview *) CollectionView layout: (uicollectionviewlayout*) collectionviewlayout Minimuminteritemspacingforsectionatindex: (nsinteger) section{return 4;}//the minimum spacing between two lines-(CGFloat) CollectionView: (Uicollectionview *) CollectionView layout: (uicollectionviewlayout*) collectionviewlayout Minimumlinespacingforsectionatindex: (nsinteger) section{return 4;}
Ios-collectionview, simple layout easy to use