Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preventing UINavigationController from adjusting origin when status bar is hidden in iOS 7

I have a series of UINavigationControllers inside a UITabBar controller. I want to hide the status bar. When I do this however, the navigation bar adjusts itself to become shorter:

Problem Image

enter image description here

How can I prevent this and get something like the picture below?

desired outcome

enter image description here

Currently I am just hiding the status bar using [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];

like image 377
jaggedcow Avatar asked Jan 15 '14 02:01

jaggedcow


Video Answer


2 Answers

Create a custom UINavigationBar with a custom sizeThatFits.

@implementation UINavigationBar (customNavigationBar)
  - (CGSize)sizeThatFits:(CGSize)size {
    CGSize newSize = CGSizeMake(self.frame.size.width,64);
    return newSize;
  }
@end

if any queries comments pls

like image 64
codercat Avatar answered Nov 11 '22 14:11

codercat


You could create a Container View inside your Storyboard and set a fixed Top Space (same as status bar). You could embed your NavigationController in this View then.

Image 1

enter image description here

Image 2

enter image description here

I hope this helps.

Edit: Added Images

like image 43
NoilPaw Avatar answered Nov 11 '22 14:11

NoilPaw