If I use a UINavigationController to display my UINavigationBar, this bar is much slimmer in landscape mode than in portrait mode.
Everything fine so far, as I want this behavior, but I have one view which isn't handled by an UINavigationController and so I just dragged and dropped a UINavigationBar from Interface Builder into the view but this one has always the same size and I can't see a way to tell the UINavigationBar that it should resize.
Anyone knows how to achieve this?
You can resize the the navigation bar in the layoutSubviews method of your UIView, like so:
- (void)layoutSubviews {
[super layoutSubviews];
// Let navBar tell us what height it would prefer at the current orientation
CGFloat navBarHeight = [navBar sizeThatFits:self.bounds.size].height;
// Resize navBar
navBar.frame = CGRectMake(0, 0, self.bounds.size.width, navBarHeight);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With