1.21学习笔记

scrollView或(tableView)实现手指上滑隐藏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;}

你可能感兴趣的:(1.21学习笔记)