iOS 隐藏状态栏

1.整个项目隐藏状态栏

在Targets->General->勾选中Hide status bar .


整个项目隐藏状态栏

2.单个界面隐藏状态栏,例如登录注册页面

  • 1.首先在info.plist里面View controller-based status bar appearance 设置为 NO.
  • 2.在需要调控状态栏的ViewController类中添加以下代码:
    //进入时隐藏
    -(void)viewWillAppear:(BOOL)animated
    {
      [super viewWillAppear:animated];
      //隐藏=YES,显示=NO; Animation:动画效果
      [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
    }
    //退出时显示
    -(void)viewWillDisappear:(BOOL)animated
    {
      [super viewWillDisappear:animated];
    //隐藏=YES,显示=NO; Animation:动画效果
      [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
    }

3.启动页隐藏状态栏,进入程序后正常显示状态栏

  • 1 .首先在Targets->General->勾选中Hide status bar或者在info.plist里面 Status bar is initially hidden 设置为 YES
  • 2.在AppDelegate.m中添加代码
    -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
    {
    [application setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
    }
posted on 2016-12-19 16:48  雨季的雾  阅读(7858)  评论(0编辑  收藏  举报