财神随手记账

HPSlideSegmentView.h 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //
  2. // HPSlideSegmentView.h
  3. // HPSlideSegmentView
  4. //
  5. // Created by 何鹏 on 17/6/12.
  6. // Copyright © 2017年 何鹏. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. @class HPSlideModel;
  10. @protocol HPSlideSegmentViewDataSouce <NSObject>
  11. /**
  12. 设置滑动内容
  13. @param slideSegmentView slideSegmentView 传入对应的ViewController 和 ViewController上面继承scrollview的对象
  14. @param index index 对应的index
  15. @return 显示的ViewController
  16. */
  17. -(UIViewController *)hp_slideListWithViewController:(HPSlideModel *)slideSegmentView index:(NSUInteger)index;
  18. @end
  19. @protocol HPSlideSegmentViewDelegate <NSObject>
  20. /**
  21. 监听当前和准备到达的index
  22. @param nowIndex 当前的index
  23. @param readyIndex 准备到达的index
  24. @param movePercent nowIndex到达readyIndex 的进度
  25. */
  26. -(void)hp_slideWithNowIndex:(NSUInteger)nowIndex readyIndex:(NSUInteger)readyIndex movePercent:(CGFloat)movePercent;
  27. @end
  28. @protocol HPSlideUpViewDelegate <NSObject>
  29. /**
  30. 获取当前显示view上面显示的mainScrollview
  31. @param mainSlideScrollView 存储当前显示的mainScrollview
  32. */
  33. -(void)hp_currentMainSlideScrollView:(UIScrollView *)mainSlideScrollView;
  34. @end
  35. @protocol HPSlideUpViewGestureClashDelegate <NSObject>
  36. /**
  37. 防止手势冲突
  38. @param gesture 返回当左右滑动时停止 多手势返回NO 当上下滑动时返回YES
  39. */
  40. -(void)hp_slideWithGestureClash:(BOOL)gesture;
  41. @end
  42. @interface HPSlideSegmentView : UIView
  43. @property(nonatomic,weak) id<HPSlideSegmentViewDataSouce> dataSource;
  44. @property(nonatomic,weak) id<HPSlideSegmentViewDelegate> delegate;
  45. @property(nonatomic,weak) id<HPSlideUpViewDelegate> upDelegate;
  46. @property(nonatomic,weak) id<HPSlideUpViewGestureClashDelegate> gestrueClashDelegate;
  47. /**
  48. 缓存个数
  49. 小于3默认为3
  50. */
  51. @property(nonatomic,assign) NSUInteger cacheMaxCount;
  52. /**
  53. 更新布局
  54. */
  55. -(void)updateLayout;
  56. /**
  57. 更新布局
  58. @param arrayCount 当前数据源的个数
  59. */
  60. -(void)updateScrollerViewWidthWidth:(NSUInteger)arrayCount;
  61. /**
  62. 更新 对应的index
  63. @param pageIndex 对应的index
  64. */
  65. -(void)updateLayout:(NSUInteger)pageIndex;
  66. /**
  67. 更新 对应的index
  68. @param pageIndex 对应的index
  69. @param update 是否需要更新代理
  70. */
  71. -(void)updateLayout:(NSUInteger)pageIndex updateDelegate:(BOOL)update;
  72. @end
  73. typedef void (^InitWithActionBlock)(HPSlideModel *model);
  74. @interface HPSlideModel : UIView
  75. /**
  76. 通过类名创建ViewController对象
  77. @param className ViewController类名
  78. @param actionBlock init 后需要执行的操作
  79. @return 返回按类名创建的对象
  80. */
  81. -(id)cacheWithClass:(Class)className initAction:(InitWithActionBlock)actionBlock;
  82. /**
  83. 通过UIStoryboard创建ViewController对象
  84. @param storyboard ViewController 的 storyboard
  85. @param identifier UIStoryboard iidentifier
  86. @return 返回创建的对象
  87. */
  88. -(id)cacheWithStoryboard:(UIStoryboard *)storyboard identifier:(NSString *)identifier ;
  89. @end