5

How can I make the view of a view controller extend to be full screen, meaning that it even resides under a translucent navigation bar?

Dan
  • 345
  • 2
  • 17
  • See if this question+answer helps? http://stackoverflow.com/questions/28251764/full-screen-background-image-while-using-uinavigationcontroller/28252325#28252325 – Romain Feb 07 '15 at 20:51
  • @Romain I don't think this will help. This is for when the nav bar is hidden. Mine is not. I set my nav bar image to be an empty image so that the buttons are displayed, but the nav bar is translucent. – Dan Feb 07 '15 at 20:55
  • "but the nav bar is translucent" --> isn't that what you're asking for? You might need to post some more info or share some code and screens to help people understand what you're trying to achieve. – Romain Feb 07 '15 at 20:58
  • @Romain the navigation bar is translucent, but the other objects of the view are 60 pixels down from the origin (0, 0) – Dan Feb 07 '15 at 21:01
  • Try to set content edges to extend below all bars: `viewController.edgesForExtendedLayout = UIRectEdgeAll;` – Romain Feb 07 '15 at 21:08

1 Answers1

2

You can place your view controller under the navigation bar.

if ([viewController respondsToSelector:@selector(setEdgesForExtendedLayout:)]) {
    [viewController setEdgesForExtendedLayout:UIRectEdgeAll];
}
Ozgur Vatansever
  • 49,246
  • 17
  • 84
  • 119
  • nevermind. Didn't work when I put it into a subclass I made. Put it into the view I was working on and now it works :) – Dan Feb 07 '15 at 21:30
  • If you want this behavior in all view controller classes in your app, I'd suggest to create a base view controller class first, then put this method in its `viewDidLoad` method and create all your view controllers as a subclass of this base class. – Ozgur Vatansever Feb 07 '15 at 21:33