美文网首页
scrollView滚动 顶部的view显示和隐藏

scrollView滚动 顶部的view显示和隐藏

作者: 怎样m | 来源:发表于2017-02-06 21:29 被阅读81次

第一种做法:

- (void)scrollViewDidScroll:(UIScrollView*)scrollView

{

CGFloatoffsetY = scrollView.contentOffset.y+self.tableView.contentInset.top;

CGFloatpanTranslationY =[scrollView.panGestureRecognizertranslationInView:self.tableView].y;

if(offsetY >0) {

if(panTranslationY >0) {

//下滑趋势显示

[selfdownScroll];

}else{

//上滑趋势隐藏

[selfupScroll];

}

}else{

//下滑趋势显示

[selfdownScroll];

}

}

第二种做法:

- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset{

if(velocity.y > 0) {

//上滑 隐藏

[self.navigationController setNavigationBarHidden:YES animated:YES];

}

else {

//下滑 出来

[self.navigationController setNavigationBarHidden:NO animated:YES];

}

}

相关文章

网友评论

      本文标题:scrollView滚动 顶部的view显示和隐藏

      本文链接:https://www.haomeiwen.com/subject/sfwuittx.html