Note: The custom function of Uicollectionview is to implement the subclass of Uicollectionviewlayout, and then rewrite the corresponding method to implement the cell layout.
1. The Preparelayout function is called when the layout is first loaded
-(void) preparelayout;
2. Custom Contentsize This method returns the size of the CollectionView, which is also a method that must be implemented in a custom layout
3. The method returns an array that holds the Uicollectionviewlayoutattributes property that is bound for each cell
-(Nsarray *) Layoutattributesforelementsinrect: (cgrect) rect;
4. To customize the properties of each cell in this method
-(Uicollectionviewlayoutattributes *) Layoutattributesforitematindexpath: (Nsindexpath *) IndexPath;
5. The method is to obtain the layoutatrributes that the cell binds to by Indexpath, and then to change some properties of the Uicollectionviewlayoutattributes object and return
-(Uicollectionviewlayoutattributes *) Layoutattributesforsupplementaryviewofkind: (NSString *) elementKind Atindexpath: (Nsindexpath *) Indexpath;
6. This method is for header view or Footerview to customize its corresponding uicollectionviewlayoutattributes
-(Uicollectionviewlayoutattributes *) Layoutattributesfordecorationviewofkind: (nsstring*) ElementKind AtIndexPath :(Nsindexpath *) Indexpath;
Uicollectionviewlayoutattributes commonly used properties:
// default is 0 // as an optimization, Uicollectionview might don't create a view for items whose hidden attribute are YES
Ios-uicollectionviewlayout Method Introduction