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

来源:互联网 发布:c语言32个关键词 编辑:程序博客网 时间:2024/05/19 21:40

在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];


这样就能避免遮盖了。


0 0
原创粉丝点击