iOS中UITableView的右侧索引设置的一些方法

主要是实现下面四个方法:

//返回section中的row

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

//返回每个索引的内容

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section

//返回索引数组

- (NSArray<NSString *> *)sectionIndexTitlesForTableView:(UITableView *)tableView

//响应点击索引时的委托方法

- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index;

当然在UITableView中还有关于索引的相关属性设置如下:

 _tableView.sectionIndexColor = [UIColor blueColor];//设置默认时索引值颜色
 _tableView.sectionIndexTrackingBackgroundColor = [UIColor grayColor];//设置选中时,索引背景颜色
 _tableView.sectionIndexBackgroundColor = [UIColor clearColor];// 设置默认时,索引的背景颜色
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容