navigationBar根据scrollview滚动显隐

来源:互联网 发布:rt809f编程器软件下载 编辑:程序博客网 时间:2024/06/18 12:09
1.修改滚动时navigationBar显隐

//遵守协议,设置代理
<UIScrollViewDelegate>
self.scView.delegate = self;

//声明UIScrollview对象scView
@property (nonatomic,strong)UIScrollView *scView;

//设置contentSize 保证scrollview可以滚动

self.scView.contentSize = CGSizeMake(ScreenWidth,ScreenHeight);

//调用代理方法,监听scrollview的滚动,设置navigationBar的显隐

-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
    [self.navigationControllersetNavigationBarHidden:NOanimated:YES];
}
-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
    [self.navigationControllersetNavigationBarHidden:YESanimated:YES];
}
//调用代理方法,是先navigation bar得显隐

-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
    [self.navigationControllersetNavigationBarHidden:NOanimated:YES];
}
-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
    [self.navigationControllersetNavigationBarHidden:YESanimated:YES];
}



0 0
原创粉丝点击