上下滑动隐藏或显示导航栏

下面是效果图。最重要的是实现UIScrollView的代理方法

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

//_lastcontentoffset上一次滑动的距离

if(scrollView.contentOffset.y>0) {

self.table.frame=CGRectMake(0,20,self.view.frame.size.width,self.view.frame.size.height-20);

[self.navigationControllersetNavigationBarHidden:YESanimated:YES];

if(scrollView.contentOffset.y-self.lastcontentoffset<=0) {

self.table=[[UITableViewalloc]initWithFrame:CGRectMake(0,64,self.view.frame.size.width,self.view.frame.size.height-64)];

[self.navigationController setNavigationBarHidden:NOanimated:YES];

}

}else{

self.table=[[UITableViewalloc]initWithFrame:CGRectMake(0,64,self.view.frame.size.width,self.view.frame.size.height-64)];

[self.navigationControllersetNavigationBarHidden:NOanimated:YES];

}

self.lastcontentoffset=scrollView.contentOffset.y;

}


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容