财神随手记账

HPSlideModuleView.h 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. //
  2. // HPSlideView.h
  3. // HPSlideSegmentView
  4. //
  5. // Created by 何鹏 on 17/6/12.
  6. // Copyright © 2017年 何鹏. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import "HPSegmentEnum.h"
  10. @class HPSlideModuleView;
  11. typedef void (^HPSLIDEMODULBUTTONBLOCK)(id weak,NSUInteger buttonIndex);
  12. @protocol SlideModuleViewDelegate <NSObject>
  13. @optional
  14. /**
  15. Button内容的设置
  16. @param index 位置
  17. @return 显示的内容
  18. */
  19. -(NSString *)hp_slideContentWithIndex:(NSUInteger)index;
  20. /**
  21. 自定义button
  22. @param index 位置
  23. @return 返回设置的button
  24. */
  25. -(UIButton *)hp_slideWithIndex:(NSUInteger)index;
  26. @end
  27. @interface HPSlideModuleView : UIView
  28. @property(nonatomic,weak) id<SlideModuleViewDelegate> delegate;
  29. @property(nonatomic,assign) BOOL spaceLine;
  30. /**
  31. 当前有多少个数据源
  32. */
  33. @property(nonatomic,assign) NSUInteger showCount;
  34. /**
  35. 滑块的背景颜色 当slideModuleView为自定义 此属性是无效
  36. */
  37. @property(nonatomic,strong) UIColor *slideModuleColor;
  38. /**
  39. 滑块view
  40. */
  41. @property(nonatomic,strong) UIView *slideModuleView;
  42. /**
  43. 滑块的宽度
  44. */
  45. @property(nonatomic,assign) CGFloat slideModeuleWidth;
  46. /**
  47. 上滑左右的边距
  48. */
  49. @property(nonatomic,assign) UIEdgeInsets edgeInsets;
  50. /**
  51. 最小大小
  52. */
  53. @property(nonatomic,assign) CGFloat minWidth;
  54. /**
  55. Button的变化样式
  56. */
  57. @property(nonatomic,assign) AutoSizeType type;
  58. /**
  59. 是否需要显示滑块
  60. */
  61. @property(nonatomic,assign) BOOL hiddenModule;
  62. /**
  63. button 没有默认的背景颜色
  64. */
  65. @property(nonatomic,strong) UIColor *backgroundDefaultColor;
  66. /**
  67. button 选择的背景颜色
  68. */
  69. @property(nonatomic,strong) UIColor *backgroundSelectColor;
  70. /**
  71. 改变当前module的位置
  72. @param index 位置
  73. */
  74. -(void)updateLayoutWithIndex:(NSUInteger)index;
  75. /**
  76. 点击事件
  77. @param weakObj 需要弱引用对象
  78. @param actionBlock 事件
  79. */
  80. -(void)hp_weak:(id)weakObj actionButton:(HPSLIDEMODULBUTTONBLOCK)actionBlock;
  81. /**
  82. 更新
  83. */
  84. -(void)updateLayout;
  85. /**
  86. 更新滑块的位置
  87. @param nowIndex 当前的位置
  88. @param readyIndex 准备到达的位置
  89. @param movePercent 当前位置到达准备位置的进度
  90. */
  91. -(void)slideWithNowIndex:(NSUInteger)nowIndex readyIndex:(NSUInteger)readyIndex movePercent:(CGFloat)movePercent;
  92. @end
  93. @interface UIButton (HPSlideSegment)
  94. /**
  95. button 的index
  96. */
  97. @property(nonatomic,assign) NSUInteger index;
  98. @end