scrollView或(tableView)實現(xiàn)手指上滑隱藏NavigationBar下滑顯示
在viewWillDisappear:方法中設置navigationBar的不隱藏:
self.navigationController.navigationBarHidden = NO;
在scrollView的代理方法中:
-(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];
}
}
判斷是否是下移,如果是下移就隱藏navigationBar
如果上滑下移的時候瓤介,頂部變黑,那么在viewDidLoad中添加如下代碼:
if ([self respondsToSelector:@selector(edgesForExtendedLayout)]){
self.edgesForExtendedLayout = UIRectEdgeNone;}