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];
}
仅做记录!