BAGridView.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*!
  2. * @header BAKit.h
  3. *
  4. * @brief BAKit
  5. *
  6. * @author 博爱
  7. * @copyright Copyright © 2016年 博爱. All rights reserved.
  8. * @version V1.0
  9. */
  10. // _ooOoo_
  11. // o8888888o
  12. // 88" . "88
  13. // (| -_- |)
  14. // O\ = /O
  15. // ____/`---'\____
  16. // . ' \\| |// `.
  17. // / \\||| : |||// \
  18. // / _||||| -:- |||||- \
  19. // | | \\\ - /// | |
  20. // | \_| ''\---/'' | |
  21. // \ .-\__ `-` ___/-. /
  22. // ___`. .' /--.--\ `. . __
  23. // ."" '< `.___\_<|>_/___.' >'"".
  24. // | | : `- \`.;`\ _ /`;.`/ - ` : | |
  25. // \ \ `-. \_ __\ /__ _/ .-` / /
  26. // ======`-.____`-.___\_____/___.-`____.-'======
  27. // `=---='
  28. //
  29. // .............................................
  30. // 佛祖镇楼 BUG辟易
  31. // 佛曰:
  32. // 写字楼里写字间,写字间里程序员;
  33. // 程序人员写程序,又拿程序换酒钱。
  34. // 酒醒只在网上坐,酒醉还来网下眠;
  35. // 酒醉酒醒日复日,网上网下年复年。
  36. // 但愿老死电脑间,不愿鞠躬老板前;
  37. // 奔驰宝马贵者趣,公交自行程序员。
  38. // 别人笑我忒疯癫,我笑自己命太贱;
  39. // 不见满街漂亮妹,哪个归得程序员?
  40. /*
  41. *********************************************************************************
  42. *
  43. * 在使用 BAKit 的过程中如果出现 bug 请及时以以下任意一种方式联系我,我会及时修复 bug
  44. *
  45. * QQ : 可以添加ios开发技术群 479663605 在这里找到我(博爱1616【137361770】)
  46. * 微博 : 博爱1616
  47. * Email : 137361770@qq.com
  48. * GitHub : https://github.com/boai
  49. * BAHome : https://github.com/BAHome
  50. * 博客 : http://boaihome.com
  51. *********************************************************************************
  52. */
  53. #import <UIKit/UIKit.h>
  54. @class BAGridItemModel, BAGridView;
  55. /**
  56. 宫格样式
  57. - BAGridViewTypeImageTitle: 上面是图片,下面是文字
  58. - BAGridViewTypeTitleDesc: 上下都是文字,上面标题字体大,下面是详情字体小
  59. */
  60. typedef NS_ENUM(NSUInteger, BAGridViewType) {
  61. BAGridViewTypeImageTitle = 0,
  62. BAGridViewTypeTitleDesc
  63. };
  64. /**
  65. BAGridView 回调
  66. @param model 返回 BAGridItemModel
  67. @param indexPath indexPath
  68. */
  69. typedef void (^BAGridViewBlock)(BAGridItemModel *model, NSIndexPath *indexPath);
  70. /**
  71. BAGridView 配置回调
  72. @param tempView BAGridView
  73. */
  74. typedef void (^BAGridView_configurationBlock)(BAGridView *tempView);
  75. @interface BAGridView : UIView
  76. /**
  77. 宫格样式,默认:BAGridViewTypeImageTitle
  78. */
  79. @property(nonatomic, assign) BAGridViewType gridViewType;
  80. /**
  81. 数据源:来自 BAGridItemModel
  82. */
  83. @property(nonatomic, strong) NSArray <BAGridItemModel *>*dataArray;
  84. /**
  85. item:点击回调
  86. */
  87. @property(nonatomic, copy) BAGridViewBlock ba_gridViewBlock;
  88. /**
  89. item:高度,图片高度 默认:ba_gridView_itemHeight * 0.4
  90. */
  91. @property(nonatomic, assign) CGFloat ba_gridView_itemHeight;
  92. /**
  93. item:图片与文字间距(或者两行文字类型的间距),默认:0
  94. */
  95. @property(nonatomic, assign) CGFloat ba_gridView_itemImageInset;
  96. /**
  97. item:每行 item 的个数,默认:4个
  98. */
  99. @property(nonatomic, assign) NSInteger ba_gridView_rowCount;
  100. /**
  101. item:title 颜色,默认:BAKit_Color_Black【[UIColor blackColor]】
  102. */
  103. @property(nonatomic, strong) UIColor *ba_gridView_titleColor;
  104. /**
  105. item:Desc 颜色,默认:BAKit_Color_Gray_9【BAKit_Color_RGB(216, 220, 228)】
  106. */
  107. @property(nonatomic, strong) UIColor *ba_gridView_titleDescColor;
  108. /**
  109. item:分割线颜色,默认:BAKit_Color_Gray_10【BAKit_Color_RGB(240, 240, 240)】
  110. */
  111. @property(nonatomic, strong) UIColor *ba_gridView_lineColor;
  112. /**
  113. item:背景颜色,默认:BAKit_Color_White
  114. */
  115. @property(nonatomic, strong) UIColor *ba_gridView_backgroundColor;
  116. /**
  117. item:背景选中颜色,默认:无色
  118. */
  119. @property(nonatomic, strong) UIColor *ba_gridView_selectedBackgroundColor;
  120. /**
  121. item:是否显示分割线
  122. */
  123. @property(nonatomic, assign, getter=isShowLineView) BOOL showLineView;
  124. /**
  125. item:title Font,默认:图文样式下 16,两行文字下(上25,下12)
  126. */
  127. @property(nonatomic, strong) UIFont *ba_gridView_titleFont;
  128. /**
  129. item:Desc Font,默认:两行文字下 12
  130. */
  131. @property(nonatomic, strong) UIFont *ba_gridView_titleDescFont;
  132. /**
  133. 快速创建宫格
  134. @param gridViewType 样式
  135. @param dataArray 数据
  136. @param configurationBlock 配置回调
  137. @param block 点击事件回调
  138. @return BAGridView
  139. */
  140. + (instancetype)ba_creatGridViewWithGridViewType:(BAGridViewType)gridViewType
  141. dataArray:(NSArray <BAGridItemModel *>*)dataArray
  142. configurationBlock:(BAGridView_configurationBlock)configurationBlock
  143. block:(BAGridViewBlock)block;
  144. @end