How to hide status bar in ios13 in cocos-2dx

201 Views Asked by At

I was using

<key>UIStatusBarHidden</key>
<true/>

in info.plist file to hide status bar for ios. Also in my RootViewController.mm is

- (BOOL)prefersStatusBarHidden 
{
   return YES;
}

to fix hiding status bar on ios7. Everything worked fine untill I tried this code on ios13. At ios13 status bar does not hide anymore. Does anybody know how to hide status bar for ios13? I also tried to add

<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>

in info.plist, but nothing seemed to work.

2

There are 2 best solutions below

0
trial4life On BEST ANSWER

Finally, I found the reason for that. my project was missing launchscreen storyboard. Adding launchscreen storyboard Seeing black bars at the top and bottom of the iPhone X Simulator and hiding safe area https://forums.developer.apple.com/thread/89037 and setting launch screen file in general settings allowed to hide status bar.

1
张鸡鸡 On

You shoudle View controller-based status bar appearance set is true

   <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/> 

    [UIApplication sharedApplication].statusBarHidden = YES;

or

   <key>UIViewControllerBasedStatusBarAppearance</key>
    <true/> 

- (BOOL)prefersStatusBarHidden{
    return YES;
}