How can I show / hide the status bar on the ViewController page using tap gestures (iOS8 / Swift)

Looking through all the solutions asked by similar questions, I try to show the statusBar to show / hide the gesture of pressing.

I set View controller-based status bar appearance = NO to plist.

I tried the following code in my DataViewController (page view manager) and in RootViewController :

 let app = UIApplication.sharedApplication() app.setStatusBarHidden(true, withAnimation: UIStatusBarAnimation.Fade) 

and it does not work.

This is built into the UITabBarController , can it change?

In addition, I was able to get the following to hide the statusBar from the RootViewController :

 override func prefersStatusBarHidden() -> Bool { return true } 

But the DataViewController does not even call this function and could hide it constantly, and not turn it on / off.

Any ideas?

+6
source share
2 answers

I tried it in code, everything works fine for me. Verify that View controller-based status bar appearance set to NO . And there is no need to redefine prefersStatusBarHidden() .

+3
source

if you are using a UIPageViewController then you should use this code in the RootViewController

if you have navigationController , it will hide it too

on ViewDidLoad()

self.navigationController?.hidesBarsOnTap = true

and use this method to hide or show the status bar based on whether the navigationBar is hidden or not

 override func prefersStatusBarHidden() -> Bool { if self.navigationController?.navigationBarHidden == true { return true } else { return false } } 
0
source

Source: https://habr.com/ru/post/978435/


All Articles