酷店

XLPageViewController.h 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //
  2. // XLPageViewController.h
  3. // XLPageViewControllerExample
  4. //
  5. // Created by MengXianLiang on 2019/5/6.
  6. // Copyright © 2019 jwzt. All rights reserved.
  7. // https://github.com/mengxianliang/XLPageViewController
  8. // 视图分页控制器
  9. #import <UIKit/UIKit.h>
  10. #import "XLPageViewControllerConfig.h"
  11. #import "XLPageViewControllerUtil.h"
  12. #import "XLPageTitleCell.h"
  13. @class XLPageViewController;
  14. NS_ASSUME_NONNULL_BEGIN
  15. @protocol XLPageViewControllerDelegate <NSObject>
  16. /**
  17. 当页面切换完成时回调该方法,返回切换到的位置
  18. @param pageViewController 实例
  19. @param index 切换的位置
  20. */
  21. - (void)pageViewController:(XLPageViewController *)pageViewController didSelectedAtIndex:(NSInteger)index;
  22. @end
  23. @protocol XLPageViewControllerDataSrouce <NSObject>
  24. @required
  25. /**
  26. 根据index返回对应的ViewController
  27. @param pageViewController XLPageViewController实例
  28. @param index 当前位置
  29. @return 返回要展示的ViewController
  30. */
  31. - (UIViewController *)pageViewController:(XLPageViewController *)pageViewController viewControllerForIndex:(NSInteger)index;
  32. /**
  33. 根据index返回对应的标题
  34. @param pageViewController XLPageViewController实例
  35. @param index 当前位置
  36. @return 返回要展示的标题
  37. */
  38. - (NSString *)pageViewController:(XLPageViewController *)pageViewController titleForIndex:(NSInteger)index;
  39. /**
  40. 要展示分页数
  41. @return 返回分页数
  42. */
  43. - (NSInteger)pageViewControllerNumberOfPage;
  44. @optional
  45. /**
  46. 自定义cell方法
  47. */
  48. - (__kindof XLPageTitleCell *)pageViewController:(XLPageViewController *)pageViewController titleViewCellForItemAtIndex:(NSInteger)index;
  49. @end
  50. @interface XLPageViewController : UIViewController
  51. /**
  52. 代理
  53. */
  54. @property (nonatomic, weak) id <XLPageViewControllerDelegate> delegate;
  55. /**
  56. 数据源
  57. */
  58. @property (nonatomic, weak) id <XLPageViewControllerDataSrouce> dataSource;
  59. /**
  60. 当前位置 默认是0
  61. */
  62. @property (nonatomic, assign) NSInteger selectedIndex;
  63. /**
  64. 滚动开关 默认 开
  65. */
  66. @property (nonatomic, assign) BOOL scrollEnabled;
  67. /**
  68. 右侧按钮
  69. */
  70. @property (nonatomic, strong) UIButton *rightButton;
  71. /**
  72. 初始化方法
  73. @param config 配置信息
  74. @return XLPageViewController 实例
  75. */
  76. - (instancetype)initWithConfig:(XLPageViewControllerConfig *)config;
  77. /**
  78. 刷新方法,当标题改变时,执行此方法
  79. */
  80. - (void)reloadData;
  81. /**
  82. 自定义标题栏cell时用到
  83. */
  84. - (void)registerClass:(Class)cellClass forTitleViewCellWithReuseIdentifier:(NSString *)identifier;
  85. /**
  86. 自定义标题栏cell时用到
  87. 返回复用的cell
  88. */
  89. - (__kindof XLPageTitleCell *)dequeueReusableTitleViewCellWithIdentifier:(NSString *)identifier forIndex:(NSInteger)index;
  90. @end
  91. NS_ASSUME_NONNULL_END