You have 2 choices.
Either create a UINavigationViewController, and set your ViewController has the rootViewController of that UINavigationViewController (it will automatically create a navigation bar with the proper status bar color on top of it),
OR you can keep your navigationBar, set its Y origin to be 20, and do the following:
In the .h file:
@interface XYZViewController : UIViewController <UIBarPositioningDelegate>
And in the .m file:
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationBar.delegate = self;
}
- (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar {
return UIBarPositionTopAttached;
}
EDIT: How to make the bar resize in phone landscape mode:
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[self.navigationBar sizeToFit];
}