MLMSegmentScroll.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. ///添加时机,默认动画或者滑动结束添加
  36. @property (nonatomic, assign) SegmentAddTiming addTiming;
  37. ///SegmentAddScale 时使用
  38. @property (nonatomic, assign) CGFloat addScale;
  39. ///给一些vc设置属性,在创建的时候,在viewController或view传入的是类名的时候使用
  40. @property (nonatomic, copy) void(^initSource)(id vcOrview, NSInteger index);
  41. - (instancetype)initWithFrame:(CGRect)frame vcOrViews:(NSArray *)sources;
  42. - (void)changeSource:(NSArray *)sources;
  43. /**
  44. * 创建之后,初始化
  45. */
  46. - (void)createView;
  47. - (NSInteger)currentIndex;
  48. - (id)currentVcOrView;
  49. @end