iOS tableView 添加索引后 索引遮盖 headview 解决办法

在tableView上添加索引后索引可能会遮盖 搜索条或headview 解决办法:
iOS tableView 添加索引后 索引遮盖 headview 解决办法
ios tableView 添加索引后 索引遮盖 Search Bar 解决办法
在TableView上方添加一个Search Bar,这里有一点需要注意,必须先把TableView拖下来,留下空间放Search Bar,不要在Table View占满屏幕的情况下把Search Bar拖到Table View顶部。区别在于,使用后面的方法,Search Bar是作为Table View的Header部分添加的,而前面的方法,Search Bar是独立的。在添加索引功能时,如果作为Table View的Header添加,右侧的索引会遮住Search Bar的右边部分。

想要避免遮盖 可以 在reloadData 前 加入:

contactsTable.sectionIndexBackgroundColor=[UIColorclearColor];
contactsTable.sectionIndexTrackingBackgroundColor = [UIColorclearColor];

// contactsTable.sectionIndexColor = [UIColor blackColor];
[contactsTablereloadData];

这样就能避免遮盖了。

你可能感兴趣的:(iOS tableView 添加索引后 索引遮盖 headview 解决办法)