您的位置:首页 > 产品设计 > UI/UE

UITableView设置headerInsectionView不悬浮

2017-09-27 16:03 1131 查看
UITableView有两个headerView:tableHeaderView、和headerInsectionView(组头视图)。

给tableView添加这两个View:tableHeaderView是通过tableView.tableHeaderView = XXXView 的方式添加的,而headerInsectionView是通过

- (UIView *)tableView:(UITableView *)tableView
viewForHeaderInSection:(NSInteger)section代理方法添加的。

UITableView的Style为Plain时,当tableView上移顶端的tableHeaderView会跟着滑出窗口,而headerInsectionView则会悬浮固定在窗口顶端不随着滑动继续上移。

UITableView的Style为Grouped时,当tableView上移顶端的tableHeaderView会跟着滑出窗口,而headerInsectionView则会随着滑动继续上移。

UITableView的Style为Plain时禁止headerInsectionView固定在顶端:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{

CGFloat sectionHeaderHeight = 50;

if(scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0)
{

scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0,0);

} else if (scrollView.contentOffset.y>=sectionHeaderHeight)
{

scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  uitableview iOS
相关文章推荐