SCIndexView.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #import <UIKit/UIKit.h>
  2. #import "SCIndexViewConfiguration.h"
  3. @class SCIndexView;
  4. @protocol SCIndexViewDelegate <NSObject>
  5. @optional
  6. /**
  7. 当点击或者滑动索引视图时,回调这个方法
  8. @param indexView 索引视图
  9. @param section 索引位置
  10. */
  11. - (void)indexView:(SCIndexView *)indexView didSelectAtSection:(NSUInteger)section;
  12. /**
  13. 当滑动tableView时,索引位置改变,你需要自己返回索引位置时,实现此方法。
  14. 不实现此方法,或者方法的返回值为 SCIndexViewInvalidSection 时,索引位置将由控件内部自己计算。
  15. @param indexView 索引视图
  16. @param tableView 列表视图
  17. @return 索引位置
  18. */
  19. - (NSUInteger)sectionOfIndexView:(SCIndexView *)indexView tableViewDidScroll:(UITableView *)tableView;
  20. @end
  21. @interface SCIndexView : UIControl
  22. @property (nonatomic, weak) id<SCIndexViewDelegate> delegate;
  23. // 索引视图数据源
  24. @property (nonatomic, copy) NSArray<NSString *> *dataSource;
  25. // 当前索引位置
  26. @property (nonatomic, assign) NSInteger currentSection;
  27. // tableView在NavigationBar上是否半透明
  28. @property (nonatomic, assign) BOOL translucentForTableViewInNavigationBar;
  29. // tableView从第几个section开始使用索引 Default = 0
  30. @property (nonatomic, assign) NSUInteger startSection;
  31. // 索引视图的配置
  32. @property (nonatomic, strong, readonly) SCIndexViewConfiguration *configuration;
  33. // SCIndexView 对 tableView 进行 weak 引用
  34. - (instancetype)initWithTableView:(UITableView *)tableView configuration:(SCIndexViewConfiguration *)configuration;
  35. // 手动更新IndexView的CurrentSection
  36. - (void)refreshCurrentSection;
  37. @end