#pragma mark - 段头不能移出屏幕的问题
-(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);
}
}
本文介绍了一种防止iOS应用中段落头部在滚动时移出屏幕的方法。通过监听scrollViewDidScroll事件调整contentInset属性,确保头部始终可见。
1723

被折叠的 条评论
为什么被折叠?



