YBShopLayout.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // YBShopLayout.h
  3. // YBLive
  4. //
  5. // Created by ybRRR on 2022/4/19.
  6. // Copyright © 2022 cat. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. typedef enum {
  10. YBWaterFlowVerticalEqualWidth = 0, /** 竖向瀑布流 item等宽不等高 */
  11. YBWaterFlowHorizontalEqualHeight = 1, /** 水平瀑布流 item等高不等宽 不支持头脚视图*/
  12. YBWaterFlowVerticalEqualHeight = 2, /** 竖向瀑布流 item等高不等宽 */
  13. YBWaterFlowHorizontalGrid = 3, /** 特为国务院客户端原创栏目滑块样式定制-水平栅格布局 仅供学习交流*/
  14. YBLineWaterFlow = 4 /** 线性布局 待完成,敬请期待 */
  15. } YBWaterFlowLayoutStyle; //样式
  16. @class YBShopLayout;
  17. @protocol YBShopLayoutDeleaget<UICollectionViewDelegateFlowLayout>
  18. /**
  19. 返回item的大小
  20. 注意:根据当前的瀑布流样式需知的事项:
  21. 当样式为WSLWaterFlowVerticalEqualWidth 传入的size.width无效 ,所以可以是任意值,因为内部会根据样式自己计算布局
  22. WSLWaterFlowHorizontalEqualHeight 传入的size.height无效 ,所以可以是任意值 ,因为内部会根据样式自己计算布局
  23. WSLWaterFlowHorizontalGrid 传入的size宽高都有效, 此时返回列数、行数的代理方法无效,
  24. WSLWaterFlowVerticalEqualHeight 传入的size宽高都有效, 此时返回列数、行数的代理方法无效
  25. */
  26. - (CGSize)waterFlowLayout:(YBShopLayout *)waterFlowLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath;
  27. /** 头视图Size */
  28. -(CGSize )waterFlowLayout:(YBShopLayout *)waterFlowLayout sizeForHeaderViewInSection:(NSInteger)section;
  29. /** 脚视图Size */
  30. -(CGSize )waterFlowLayout:(YBShopLayout *)waterFlowLayout sizeForFooterViewInSection:(NSInteger)section;
  31. @optional //以下都有默认值
  32. /** 列数*/
  33. -(CGFloat)columnCountInWaterFlowLayout:(YBShopLayout *)waterFlowLayout;
  34. /** 行数*/
  35. -(CGFloat)rowCountInWaterFlowLayout:(YBShopLayout *)waterFlowLayout;
  36. /** 列间距*/
  37. -(CGFloat)columnMarginInWaterFlowLayout:(YBShopLayout *)waterFlowLayout;
  38. /** 行间距*/
  39. -(CGFloat)rowMarginInWaterFlowLayout:(YBShopLayout *)waterFlowLayout;
  40. /** 边缘之间的间距*/
  41. -(UIEdgeInsets)edgeInsetInWaterFlowLayout:(YBShopLayout *)waterFlowLayout;
  42. @end
  43. @interface YBShopLayout : UICollectionViewLayout
  44. @property (nonatomic, weak) id<YBShopLayoutDeleaget> delegate;
  45. /** 瀑布流样式*/
  46. @property (nonatomic, assign) YBWaterFlowLayoutStyle flowLayoutStyle;
  47. @end