0
votes

I want to show some notice on top bar without showing navigation bar and status bar. So first of all, I hide two bars, and show some notice and then show two bars.

My problem is that I can hide bars and show the notice. But when I tried to show two bars, it affects notice. That is, as I hide bars and show notice which disappears by animation, I could check bars were gone. But as soon as I put code 'show bars', as notice shows, status bar and navigation bar also shows.

My codes are as follows:

Hide navigation Bar

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

Show notice

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

I don't know what I missed some points to deal with hiding navigation bar and status bar. Please let me know. Thanks in advance.

1

1 Answers

0
votes

Not sure what topBar refers to in your code but to hide or show the navigationBar you would generally use the following code

To hide:

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

And to show:

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