《省钱达人》与《猎豆优选》UI相同版。域名tbk

BuyLimitHeader.h 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. //
  2. // BuyLimitHeader.h
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/7/6.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import "MLMSegmentScroll.h"
  10. typedef enum : NSUInteger {
  11. /**
  12. * 默认
  13. */
  14. BuyLimitHeadStyleDefault,
  15. /**
  16. * line(下划线)
  17. */
  18. BuyLimitHeadStyleLine,
  19. /**
  20. * arrow(箭头)
  21. */
  22. BuyLimitHeadStyleArrow,
  23. /**
  24. * Slide(滑块)
  25. */
  26. BuyLimitHeadStyleSlide
  27. } BuyLimitHeadStyle;
  28. /**
  29. *
  30. * 分割样式,默认均分,其他样式按照标题长度计算
  31. */
  32. typedef enum : NSUInteger {
  33. /*
  34. * 默认均分,根据maxTitles计算宽度,均分
  35. */
  36. BuyLimitLayoutDefault,
  37. /*
  38. * 居中(标题不足一屏时选择样式,反之设置后按照居左)
  39. */
  40. BuyLimitLayoutCenter,
  41. /*
  42. * 居左
  43. */
  44. BuyLimitLayoutLeft
  45. } BuyLimitLayoutStyle;
  46. @protocol BuyLimitHeadDelegate <NSObject>
  47. /**
  48. * selected
  49. *
  50. * @param index index
  51. */
  52. - (void)didSelectedIndex:(NSInteger)index;
  53. @end
  54. @interface BuyLimitHeader : UIView
  55. /**
  56. * 初始化显示的下标。默认显示0
  57. */
  58. @property (nonatomic, assign) NSInteger showIndex;
  59. /**
  60. * 导航条的背景颜色
  61. */
  62. @property (nonatomic, strong) UIColor *headColor;
  63. /**
  64. * 非均分样式下按钮宽度 = 计算 + singleW_Add
  65. */
  66. @property (nonatomic, assign) CGFloat singleW_Add;
  67. /**
  68. * 设置完成后更改self的宽度 = titlesScroll.contentSize.width
  69. */
  70. @property (nonatomic, assign) BOOL equalSize;
  71. /*------------自定义导航栏可不设置------------*/
  72. /**
  73. * 选择状态下的颜色,完全自定义样式下可不设置
  74. */
  75. @property (nonatomic, strong) UIColor *selectColor;
  76. /**
  77. * 未选中状态下的颜色,完全自定义样式下可不设置
  78. */
  79. @property (nonatomic, strong) UIColor *deSelectColor;
  80. /**
  81. * 字体的大小,完全自定义样式下可不设置
  82. */
  83. @property (nonatomic, assign) CGFloat fontSize;
  84. /**
  85. * 选中状态的缩放比例,SegmentHeadStyleSlide风格下此属性无用,设置缩放比例滑动过程中会有相应动画
  86. */
  87. @property (nonatomic, assign) CGFloat fontScale;
  88. /**
  89. * 是否有背景图片
  90. */
  91. @property (nonatomic, assign) BOOL hadBackImg;
  92. ///背景图
  93. @property (nonatomic, strong) NSArray *backImages;
  94. /*------------添加更多按钮样式------------*/
  95. /**
  96. * 添加更多样式
  97. */
  98. @property (nonatomic, strong) UIView *moreButton;
  99. /**
  100. * 更多按钮宽度
  101. */
  102. @property (nonatomic, assign) CGFloat moreButton_width;
  103. /*------------下划线风格------------*/
  104. /**
  105. * 下划线的颜色
  106. */
  107. @property (nonatomic, strong) UIColor *lineColor;
  108. /**
  109. * 下划线高度
  110. */
  111. @property (nonatomic, assign) CGFloat lineHeight;
  112. /**
  113. * 下划线相对于正常状态下的百分比,默认为1
  114. */
  115. @property (nonatomic, assign) CGFloat lineScale;
  116. /*------------箭头风格------------*/
  117. /**
  118. * 箭头的颜色
  119. */
  120. @property (nonatomic, strong) UIColor *arrowColor;
  121. /*------------滑块风格------------*/
  122. /**
  123. * 滑块的颜色
  124. */
  125. @property (nonatomic, strong) UIColor *slideColor;
  126. /**
  127. * 滑块的高度
  128. */
  129. @property (nonatomic, assign) CGFloat slideHeight;
  130. /**
  131. * 滑块的圆角大小
  132. */
  133. @property (nonatomic, assign) CGFloat slideCorner;
  134. /**
  135. * 滑块相对于正常状态下的百分比,默认为1
  136. */
  137. @property (nonatomic, assign) CGFloat slideScale;
  138. @property (nonatomic, strong) NSArray *subTitles;
  139. /**
  140. * 顶部导航栏下方的边线
  141. */
  142. @property (nonatomic, assign) CGFloat bottomLineHeight;
  143. @property (nonatomic, strong) UIColor *bottomLineColor;
  144. /**
  145. * 设置当前屏幕最多显示的按钮数,只有在默认布局样式 - MLMSegmentLayoutDefault 下使用
  146. */
  147. @property (nonatomic, assign) CGFloat maxTitles;
  148. /**
  149. * 代理
  150. */
  151. @property (nonatomic, weak) id<BuyLimitHeadDelegate> delegate;
  152. /**
  153. * block
  154. */
  155. @property (nonatomic, copy) void(^selectedIndex)(NSInteger);
  156. /**
  157. * init method
  158. *
  159. * @param frame frame
  160. * @param titles titles array
  161. *
  162. * @return SegmentHeadView
  163. */
  164. - (instancetype)initWithFrame:(CGRect)frame
  165. titles:(NSArray *)titles;
  166. /**
  167. * init method
  168. *
  169. * @param frame frame
  170. * @param titles titles array
  171. * @param style SegmentHeadStyle
  172. *
  173. * @return SegmentHeadView
  174. */
  175. - (instancetype)initWithFrame:(CGRect)frame
  176. titles:(NSArray *)titles
  177. headStyle:(BuyLimitHeadStyle)style;
  178. /**
  179. * init method
  180. *
  181. * @param frame frame
  182. * @param titles titles array
  183. * @param style SegmentHeadStyle
  184. * @param layout MLMSegmentLayoutStyle
  185. *
  186. * @return SegmentHeadView
  187. */
  188. - (instancetype)initWithFrame:(CGRect)frame
  189. titles:(NSArray *)titles
  190. headStyle:(BuyLimitHeadStyle)style
  191. layoutStyle:(BuyLimitLayoutStyle)layout;
  192. /**
  193. * set currentIndex
  194. *
  195. * @param index , set currendIndex
  196. */
  197. - (void)setSelectIndex:(NSInteger)index;
  198. /**
  199. * animation by scale
  200. *
  201. * @param scale scale
  202. */
  203. - (void)changePointScale:(CGFloat)scale;
  204. /**
  205. * 在SegmentHeadStyleLine样式下,返回下划线view,可以根据自己的需求进行进一步定制,如自定义UIImageView添加
  206. *
  207. * @return SegmentHeadStyleLine样式下,下划线view
  208. */
  209. - (UIView *)getScrollLineView;
  210. /**
  211. * 返回导航栏下方的下划线,可根据需求进行定制,如绘制虚线,添加UIImageView等
  212. *
  213. * @return 返回导航栏下方的下划线
  214. */
  215. - (UIView *)getBottomLineView;
  216. /**
  217. * get sumWidth
  218. */
  219. - (CGFloat)getSumWidth;
  220. /**
  221. * 创建之后,初始化
  222. */
  223. - (void)defaultAndCreateView;
  224. /**
  225. * *重要*:与之关联的scroll动画结束调用
  226. */
  227. - (void)animationEnd;
  228. /**
  229. 更改titles
  230. @param titles title的数组
  231. */
  232. - (void)changeTitle:(NSArray *)titles;
  233. /**
  234. 下划线的view,用于自定义,如添加图片
  235. @return 下划线的view
  236. */
  237. - (UIView *)getLineView;
  238. - (UIScrollView *)titlesScroll;
  239. - (NSArray *)buttons;
  240. - (void)changeIndex:(NSInteger)index completion:(BOOL)completion;
  241. - (void)changeIndex:(NSInteger)index completion:(BOOL)completion animate:(BOOL)animate ;
  242. @end