省钱达人

MLMSegmentScroll.h 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //
  2. // MLMSegmentScroll.h
  3. // MLMSegmentPage
  4. //
  5. // Created by my on 2017/2/6.
  6. // Copyright © 2017年 my. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. //添加子视图的时机
  10. typedef enum : NSUInteger {
  11. SegmentAddNormal,//滑动或者动画结束
  12. SegmentAddScale//根据设置滑动百分比添加0-1
  13. } SegmentAddTiming;
  14. @protocol MLMSegmentScrollDelegate <NSObject>
  15. ///滑动结束
  16. - (void)scrollEndIndex:(NSInteger)index;
  17. ///动画结束
  18. - (void)animationEndIndex:(NSInteger)index;
  19. ///偏移的百分比
  20. - (void)scrollOffsetScale:(CGFloat)scale;
  21. @end
  22. @interface MLMSegmentScroll : UIScrollView
  23. ///第一次进入是否加载,YES加载countLimit个页面,默认 - NO
  24. @property (nonatomic, assign) BOOL loadAll;
  25. ///缓存页面数目,默认 - all
  26. @property (nonatomic, assign) NSInteger countLimit;
  27. ///默认显示开始的位置,默认 - 1
  28. @property (nonatomic, assign) NSInteger showIndex;
  29. ///delegate
  30. @property (nonatomic, weak) id<MLMSegmentScrollDelegate> segDelegate;
  31. ///blcok
  32. @property (nonatomic, copy) void(^scrollEnd)(NSInteger);
  33. @property (nonatomic, copy) void(^animationEnd)(NSInteger);
  34. @property (nonatomic, copy) void(^offsetScale)(CGFloat);
  35. @property (nonatomic, copy) void(^showingIndex)(NSInteger);
  36. ///添加时机,默认动画或者滑动结束添加
  37. @property (nonatomic, assign) SegmentAddTiming addTiming;
  38. ///SegmentAddScale 时使用
  39. @property (nonatomic, assign) CGFloat addScale;
  40. ///给一些vc设置属性,在创建的时候,在viewController或view传入的是类名的时候使用
  41. @property (nonatomic, copy) void(^initSource)(id vcOrview, NSInteger index);
  42. - (instancetype)initWithFrame:(CGRect)frame vcOrViews:(NSArray *)sources;
  43. - (void)changeSource:(NSArray *)sources;
  44. /**
  45. * 创建之后,初始化
  46. */
  47. - (void)createView;
  48. - (NSInteger)currentIndex;
  49. - (id)currentVcOrView;
  50. @end