天天省钱快报

WSLWaterFlowLayout.h 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // WSLWaterFlowLayout.h
  3. // collectionView
  4. //
  5. // Created by 王双龙 on 2017/10/16.
  6. // Copyright © 2017年 https://www.jianshu.com/u/e15d1f644bea All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. typedef enum {
  10. WSLVerticalWaterFlow = 0, /** 竖向瀑布流 item等宽不等高 */
  11. WSLHorizontalWaterFlow = 1, /** 水平瀑布流 item等高不等宽 不支持头脚视图*/
  12. WSLVHWaterFlow = 2, /** 竖向瀑布流 item等高不等宽 */
  13. WSLLineWaterFlow = 3 /** 线性布局 待完成,敬请期待 */
  14. } WSLFlowLayoutStyle; //样式
  15. @class WSLWaterFlowLayout;
  16. @protocol WSLWaterFlowLayoutDelegate <NSObject>
  17. /** 竖向瀑布流 item等宽不等高 */
  18. -(CGFloat)waterFlowLayout:(WSLWaterFlowLayout *)waterFlowLayout heightForItemAtIndexPath:(NSIndexPath *)indexPath itemWidth:(CGFloat)itemWidth;
  19. /** 水平瀑布流 item等高不等宽 */
  20. -(CGFloat)waterFlowLayout:(WSLWaterFlowLayout *)waterFlowLayout widthForItemAtIndexPath:(NSIndexPath *)indexPath itemHeight:(CGFloat)itemHeight;
  21. /** 竖向瀑布流 item等高不等宽 列数、行数无用*/
  22. - (CGSize)waterFlowLayout:(WSLWaterFlowLayout *)waterFlowLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath;
  23. /** 头视图Size */
  24. -(CGSize )waterFlowLayout:(WSLWaterFlowLayout *)waterFlowLayout sizeForHeaderViewInSection:(NSInteger)section;
  25. /** 脚视图Size */
  26. -(CGSize )waterFlowLayout:(WSLWaterFlowLayout *)waterFlowLayout sizeForFooterViewInSection:(NSInteger)section;
  27. @optional //以下都有默认值
  28. /** 列数*/
  29. -(CGFloat)columnCountInWaterFlowLayout:(WSLWaterFlowLayout *)waterFlowLayout;
  30. /** 行数*/
  31. -(CGFloat)rowCountInWaterFlowLayout:(WSLWaterFlowLayout *)waterFlowLayout;
  32. /** 列间距*/
  33. -(CGFloat)columnMarginInWaterFlowLayout:(WSLWaterFlowLayout *)waterFlowLayout;
  34. /** 行间距*/
  35. -(CGFloat)rowMarginInWaterFlowLayout:(WSLWaterFlowLayout *)waterFlowLayout;
  36. /** 边缘之间的间距*/
  37. -(UIEdgeInsets)edgeInsetInWaterFlowLayout:(WSLWaterFlowLayout *)waterFlowLayout;
  38. @end
  39. @interface WSLWaterFlowLayout : UICollectionViewLayout
  40. /** delegate*/
  41. @property (nonatomic, weak) id<WSLWaterFlowLayoutDelegate> delegate;
  42. /** 瀑布流样式*/
  43. @property (nonatomic, assign) WSLFlowLayoutStyle flowLayoutStyle;
  44. @end