Can't hide status bar on launch

送分小仙女□ 提交于 2019-12-05 10:05:41

Just tick the hide status bar in project setting as below.

  1. Project setting - For hiding the status bar at launch of app.

  1. Add below in viewController for which you need to hide.

- (BOOL)prefersStatusBarHidden { return YES; }

/------ UPDATE -----/

  1. With tick of hide status bar

  2. Without tick of hide status bar

/------ Animate Status Bar -----/

In plist.

View controller-based status bar appearance = NO

Then in viewWillAppear method.

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
changing plist file : 

set Status bar is initially hidden = YES

add row: View controller-based status bar appearance = NO

In order to achieve what you are looking for you need set in the app.plistfile:

Status bar is initially hidden to YES

View controller-based status bar appearance to NO

Then in every view controller to show it

[[UIApplication sharedApplication] setStatusBarHidden:NO];

or to hide it:

[[UIApplication sharedApplication] setStatusBarHidden:YES];

Goto Targets->General->Deployment Info: and under that select Hide Status Bar option.

Turns out what I was doing was correct, but there was an errant [[UIApplication sharedApplication] setStatusBarHidden:NO]; buried in inherited code. I grepped it, but overlooked that line...

(use git grep StatusBar to find lines of code in a git repo that mutate the status bar)

Also, the only code needed is:

View controller-based status bar appearance = NO (in plist)

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

anywhere the status bar needs updating (usually in viewWillAppear)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!