【问题标题】:hide status bar and UINavigationBar on ios在 ios 上隐藏状态栏和 UINavigationBar
【发布时间】:2014-02-01 17:17:36
【问题描述】:

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

我的问题是我可以隐藏栏并显示通知。但是当我尝试显示两个条时,它会影响通知。也就是说,当我隐藏条形图并显示动画消失的通知时,我可以检查条形图消失了。但是只要我把代码“显示栏”,通知显示,状态栏和导航栏也会显示。

我的代码如下:

隐藏导航栏

- (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);
}];
}

我不知道我在处理隐藏导航栏和状态栏时遗漏了什么。请告诉我。提前致谢。

【问题讨论】:

    标签: ios uinavigationcontroller uinavigationbar


    【解决方案1】:

    不确定 topBar 在您的代码中指的是什么,但要隐藏或显示导航栏,您通常会使用以下代码

    隐藏:

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

    并显示:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-20
      • 1970-01-01
      • 2017-03-20
      • 2014-04-23
      • 2014-11-14
      相关资源
      最近更新 更多