取消TableView的headerView和footerView的悬停效果

来源:互联网 发布:windows ping包 编辑:程序博客网 时间:2024/05/20 05:06
-(void)scrollViewDidScroll:(UIScrollView *)scrollView {    if (scrollView == self.tableView)    {        UITableView *tableview = (UITableView *)scrollView;        CGFloat sectionHeaderHeight = 64;        CGFloat sectionFooterHeight = 44;        CGFloat offsetY = tableview.contentOffset.y;        if (offsetY >= 0 && offsetY <= sectionHeaderHeight)        {            tableview.contentInset = UIEdgeInsetsMake(-offsetY, 0, -sectionFooterHeight, 0);        }else if (offsetY >= sectionHeaderHeight && offsetY <= tableview.contentSize.height - tableview.frame.size.height - sectionFooterHeight)        {            tableview.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, -sectionFooterHeight, 0);        }else if (offsetY >= tableview.contentSize.height - tableview.frame.size.height - sectionFooterHeight && offsetY <= tableview.contentSize.height - tableview.frame.size.height)        {            tableview.contentInset = UIEdgeInsetsMake(-offsetY, 0, -(tableview.contentSize.height - tableview.frame.size.height - sectionFooterHeight), 0);        }    }}

讲上述代码粘进控制器中即可

0 0