在ios上隐藏状态栏和UINavigationBar

时间:2014-02-01 17:17:37

标签: ios uinavigationcontroller uinavigationbar

我想在顶部栏上显示一些通知而不显示导航栏和状态栏。 首先,我隐藏了两个条形图,并显示一些通知然后显示两个条形图。

我的问题是我可以隐藏栏并显示通知。但当我试图显示两个酒吧时,它会影响通知。也就是说,当我隐藏条形并显示通过动画消失的通知时,我可以检查条形图已经消失。但是,只要我将代码“显示栏”放入,如通知所示,状态栏和导航栏也会显示。

我的代码如下:

隐藏导航栏

- (void)hideNavigationBar {

[[UIApplication sharedApplication] setStatusBarHidden:YES 
withAnimation:UIStatusBarAnimationSlide];
isNavigationBarShowing = NO;
[UIView animateWithDuration:0.35 animations:^{
    topBar.frame = CGRectMake(0, - topBar.frame.size.height, topBar.frame.size.width, topBar.frame.size.height);
}];
}

显示通知

- (void) showNotice {
[UIView animateWithDuration:0.3 animations:^{
        noticeLabel.frame = CGRectMake(0, 0, 320, 64);
    } completion:^(BOOL finished) {
        [UIView animateWithDuration:0.3 delay:1.0f 
options:UIViewAnimationOptionCurveLinear animations:^{
            noticeLabel.frame = CGRectMake(0, -85, 320, 64);
        } completion:nil];
    }];
}


- (void) showNavigationBar {
[[UIApplication sharedApplication] setStatusBarHidden:NO   withAnimation:UIStatusBarAnimationSlide];
isNavigationBarShowing = YES;
 topBar.frame = CGRectMake(0, - topBar.frame.size.height, topBar.frame.size.width,   topBar.frame.size.height);
 [UIView animateWithDuration:0.35 animations:^{
    topBar.frame = CGRectMake(0, statusBarHeight, topBar.frame.size.width, topBar.frame.size.height);
}];
}

我不知道我错过了哪些点来处理隐藏导航栏和状态栏。请告诉我。提前致谢。

1 个答案:

答案 0 :(得分:0)

不确定topBar在您的代码中引用了什么,但要隐藏或显示navigationBar,您通常会使用以下代码

隐藏:

[self.navigationController setNavigationBarHidden:YES animated:YES];

并表示:

[self.navigationController setNavigationBarHidden:NO animated:YES];
相关问题