效果图
功能及优点
主要功能及优点如下:
- 当滑动 UITableView 列表时,索引视图的索引位置会跟着移动;
- UITableView 和 SCIndexView 之间手势和事件不冲突,操作其中一个视图,另一个视图失效;
- 当滑动索引视图时,会有指示器或者 toast 提示当前索引位置;
- 索引视图可以从 sc_startSection 开始,忽略前面 section;
- 可以任意定制指示器、toast、索引视图的大小,文字颜色大小,间距等 UI 样式;
- 当第一个数据为 UITableViewIndexSearch 时,自动添加放大镜图标。
使用方法
可以通过 CocoaPods 导入,支持 iOS7 及以上。
pod 'SCIndexView'
- 创建 SCIndexViewConfiguration 对象,这个对象用来控制索引的 UI 样式;
- 设置 UITableViewDataSource 对象的 sc_translucentForTableViewInNavigationBar 和 sc_indexViewConfiguration;
- 再设置 UITableViewDataSource 对象的索引数据源。 不用再关心 SCIndexView 视图本身,直接在 UITableViewDataSource 上设置即可。
SCIndexViewConfiguration *indexViewConfiguration = [SCIndexViewConfiguration configuration];
tableView.sc_indexViewConfiguration = indexViewConfiguration;
tableView.sc_translucentForTableViewInNavigationBar = YES;
tableView.sc_indexViewDataSource = indexViewDataSource;
结束
如果您有任何想法,欢迎向我反馈。如果您喜欢它,也可以通过 star 来鼓励我,感谢大家的支持。