被人问到cocos2d-x项目怎么显示状态栏,其实状态隐藏与否跟cocos2dx一点关系都没有,只是2dx的模板cpp-template-default写死了。
因某度娘跟某谷姐都只有一堆 how to hide the status bar,就此撸一下 how to show status bar for cocos2d-x projects.
本文只做简单的显示设置,有兴趣深入的可以戳 iOS7下隐藏status bar的详细研究
-
Info.plist
-
View controller-based status bar appearance
NO
这是status bar的设置优先级 -
Status bar is initially hidden
NO
AppController.mm
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// ...
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
[[UIApplication sharedApplication] setStatusBarHidden: NO];
// Add the view controller's view to the window and display.
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] /*bounds*/applicationFrame]];
//...
}
RootViewController.mm
//fix not hide status on ios7
- (BOOL)prefersStatusBarHidden
{
return NO; //修改为NO, 2dx模板为YES
}
2d-js helloword 状态栏预览