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

2017-02-06  本文已影响81人  怎样m

第一种做法:

- (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];

}

}

上一篇 下一篇

猜你喜欢

热点阅读