-1

I want to customize a toast view which needs to hide the status bar. Before iOS 13, I get the status bar by enter image description here. But in iOS 13 it will crash. So is there some ways to get the status bar in iOS 13? Or does anybody know other ways to solve my demand.

Grayson
  • 41
  • 8

4 Answers4

1
-(BOOL)prefersStatusBarHidden {
    return true;
}

Use this method.

phani
  • 105
  • 2
  • 15
  • But this has to be achieved in the controller. I want to hide the status bar in my custom view. – Grayson Jan 03 '20 at 06:08
0

Add this in info.plist file (open it in source mode):

<key>UIStatusBarHidden</key>
<true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
Nirbhay Singh
  • 1,204
  • 1
  • 12
  • 16
  • I don't want to set the View controller-based status bar appearance to NO and I can't let the statusBar be hidden all the time. Any other idea? – Grayson Jan 03 '20 at 06:23
  • Set this on your custom view controller class: -(BOOL)prefersStatusBarHidden { return false; } – Nirbhay Singh Jan 03 '20 at 06:25
  • I am customizing a toast view. When the view shows up, the status bar will be hid. When the view disappears, the status bar will show up. – Grayson Jan 03 '20 at 07:27
0

If you want to hide/show status bar on the different view controllers for iOS 13 then you need to do this :

  1. Add View controller-base status bar appearance option in your Info.plist and set it to YES
  2. Override var prefersStatusBarHidden: Bool in each View Controller where you want to have the status bar shown/hidden

Refer this answer for more information in a detail.

Dhaval Raval
  • 594
  • 2
  • 7
0

Try this :

UIApplication.sharedApplication.statusBarHidden = true;
snibbe
  • 2,715
  • 1
  • 27
  • 34
Nirbhay Singh
  • 1,204
  • 1
  • 12
  • 16