Reputation: 11
I was just wondering if there is a simple way to specify whether a UINavigationBar
should overlay its content when shown. I currently have a UINavigationController
that contains a custom UIViewController
with a UIScrollView
, which contains a UIPageViewController
(I wanted a zooming/scrollable UIPageViewController
).
When I call:
[self setNavigationBarHidden:NO animated:YES];
From within my UINavigationController
, the UINavigationBar
animates in, but pushes the custom container with all its content down, instead of overlaying it.
The bar is set to translucent and I've tried all the settings I can think of. I changed the extendEdges
settings in the child view controllers and that resized the content when the navigation bar came in, instead of pushing it down. But I still can't work out how to get it to overlay instead.
Many thanks.
Upvotes: 0
Views: 321
Reputation: 11
Ok, apologies. This just reveals how little I know about iOS programming...
I noticed that the container's view origin y value was -44. So adding the following within my container class:
- (void) viewDidLayoutSubviews
{
CGRect boundsRect = self.view.bounds;
boundsRect.origin = CGPointMake(0, 0);
self.view.bounds = boundsRect;
}
Results in the view staying at the top of the screen, so the UINavigationBar
overlays it nicely when it appears.
EDIT: Actually the proper way appears to be just calling:
self.automaticallyAdjustsScrollViewInsets = NO;
Upvotes: 1