1、如果选择不让HeaderView悬浮
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat sectionHeaderHeight = 40;
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);
}
}
2、如果选择让HederView悬浮
if scrollView.isEqual(scheduleTableView){
let sectionHeaderHeight: CGFloat = 44;
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 = UIEdgeInsetsZero
}
}
处理完成以后,然后
strongSelf.scheduleTableView.scrollToRowAtIndexPath(indexArray.index, atScrollPosition: .Middle, animated: false) 滚动到指定行,完成效果
参考:http://blog.csdn.net/hopedark/article/details/44175695
http://www.geekcome.com/content-10-2518-1.html