SheetView.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // SheetView.h
  3. // SheetViewDemo
  4. //
  5. // Created by Mengmin Duan on 2017/7/19.
  6. // Copyright © 2017年 Mengmin Duan. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <UIKit/UIKit.h>
  10. @class SheetView;
  11. @protocol SheetViewDataSource <NSObject>
  12. @required
  13. //返回表格有多少行
  14. - (NSInteger)sheetView:(SheetView *)sheetView numberOfRowsInSection:(NSInteger)section;
  15. //返回表格有多少列
  16. - (NSInteger)sheetView:(SheetView *)sheetView numberOfColsInSection:(NSInteger)section;
  17. //返回表格某行某列位置上需要显示的内容
  18. - (NSString *)sheetView:(SheetView *)sheetView cellForContentItemAtIndexRow:(NSIndexPath *)indexRow indexCol:(NSIndexPath *)indexCol;
  19. //返回表格左侧标题列每行需要显示的内容
  20. - (NSString *)sheetView:(SheetView *)sheetView cellForLeftColAtIndexPath:(NSIndexPath*)indexPath;
  21. //返回表格上边标题行每列需要显示的内容
  22. - (NSString *)sheetView:(SheetView *)sheetView cellForTopRowAtIndexPath:(NSIndexPath*)indexPath;
  23. @optional
  24. //返回表格某行是否需要填充颜色
  25. - (BOOL)sheetView:(SheetView *)sheetView cellWithColorAtIndexRow:(NSIndexPath *)indexRow;
  26. @end
  27. @protocol SheetViewDelegate <NSObject>
  28. @required
  29. //返回表格每行的高度
  30. - (CGFloat)sheetView:(SheetView *)sheetView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
  31. //返回表格每列的宽度
  32. - (CGFloat)sheetView:(SheetView *)sheetView widthForColAtIndexPath:(NSIndexPath *)indexPath;
  33. - (void)sheetView:(SheetView *)sheetView didSelectItemAtIndexRow:(NSIndexPath *)indexRow indexCol:(NSIndexPath *)indexCol;
  34. @end
  35. @interface SheetView : UIView
  36. @property (nonatomic, strong) id<SheetViewDataSource> dataSource;
  37. @property (nonatomic, strong) id<SheetViewDelegate> delegate;
  38. @property (nonatomic, strong) NSString *sheetHead;//第一行第一列格子要显示的内容
  39. @property (nonatomic, assign) CGFloat titleColWidth;//左侧标题列宽度(必须设置)
  40. @property (nonatomic, assign) CGFloat titleRowHeight;//上边标题行高度(必须设置)
  41. //表格刷新
  42. - (void)reloadData;
  43. @end