0

Please Read the question before marking it as duplicate.

I know there are a lot of questions regarding Hiding Status Bar of a View Controller in iOS. But none of them solves my problem.

I am using Swift - 3.0 Here is my scenario:

  1. I am able to hide status bar on a single UIViewController using prefersStatusBarHidden computed property. So no problem with that.

  2. I have a UIPageViewController(DetailPageViewController) that contains several UIViewControllers(DetailViewController) as child controllers. In each of those child view controllers, I have another UIPageViewController(PhotosPageViewController) which further contains multiple UIViewControllers(PhotoViewController). i.e.,

DetailPageViewController --> multiple DetailViewController

each DetailViewController --> PhotosPageViewController --> multiple PhotoViewController

So, the problem is I am not able to hide status bar of all the 4 controllers - DetailPageViewController, DetailViewController, PhotosPageViewController, PhotoViewController

PGDev
  • 23,751
  • 6
  • 34
  • 88
  • I am not sure.but,you should be looking at `var childViewControllerForStatusBarHidden: UIViewController? { get }` to achieve this function.for more info https://developer.apple.com/reference/uikit/uiviewcontroller/1621440-prefersstatusbarhidden – Joe Nov 21 '16 at 14:18
  • I tried this already..but no luck. – PGDev Nov 21 '16 at 14:19
  • i wondering.how many VC does have statusBar in your project or only in mainVC? – Joe Nov 21 '16 at 14:23

1 Answers1

0

You can either hide Status Bar from storyboard for each view controller you are initialize just chose none for that mater

enter image description here enter image description here

or you can create a BaseViewController and do it programmatically and subclass your controller from BaseViewController

BaseViewController: UIViewController {
    override var prefersStatusBarHidden: Bool {
       return true
    }
}

DetailViewController: BaseViewController {
   // your codes goes here
}

Beware of that if you use this method it is only gonna work on controllers that is inherit from UIViewController and not UITableViewController or such,In that case you should create such file for them to if you have few of them.

Hope this will help

Arashk
  • 617
  • 5
  • 16