Unable to hide statusbar in single UIViewController

前端 未结 4 1341
感情败类
感情败类 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: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];
    

提交回复
热议问题