Unable to hide statusbar in single UIViewController

前端 未结 4 1339
感情败类
感情败类 2021-01-23 14:25

I want to hide staus bar in single view controller but my code is not working. I\'m using the below code

-(BOOL)prefersStatusBarHidden
{
    return YES;
}


        
相关标签:
4条回答
  • 2021-01-23 14:33

    To hide status bar on a single VC:

    1) Add this value to plist:

    "View controller-based status bar appearance" and set it to "YES"

    2) Add following to viewWillAppear:

    [self prefersStatusBarHidden];
    

    3) Add new method:

    -(BOOL)prefersStatusBarHidden
    {
        return YES; 
    }
    
    0 讨论(0)
  • 2021-01-23 14:47

    if you have View controller-based status bar appearance set to YES in app's plist, put this code in the view controller:

    - (BOOL)prefersStatusBarHidden {
        return YES;
    }
    

    and if View controller-based status bar appearance is set to NO, do the following whenever you want to hide the status bar.

    [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
    
    0 讨论(0)
  • 2021-01-23 14:50

    try this one it's help for me-:

    -(BOOL)prefersStatusBarHidden
    {
    
      return YES;
    
    }
    
    0 讨论(0)
  • 2021-01-23 14:56

    You should add this value to plist: "View controller-based status bar appearance" and set it to "NO".

    or

    in

    application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions write
    
     [[UIApplication sharedApplication] setStatusBarHidden:YES];
    

    or

    Add following line in viewdidload

    [[UIApplication sharedApplication] setStatusBarHidden:YES
                                            withAnimation:UIStatusBarAnimationFade];
    

    and add new method

     - (BOOL)prefersStatusBarHidden {
              return YES;
      }
    
    0 讨论(0)
提交回复
热议问题