Reputation: 4475
I use Xcode 5 to create a master detail project. The default navigation bar looks like this:
Now I create a new UIViewContrller file and its xib file:
I add a NavigationBar to the view, and set background color green, but the status bar area is in navigation bar.How to config it as MasterController navigation bar display?
Upvotes: 2
Views: 1853
Reputation: 8049
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];
}
Upvotes: 5