被人问到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 状态栏预览
Cocos2d-x状态栏显示
本文介绍如何在Cocos2d-x项目中显示状态栏。通过修改Info.plist文件和AppController.mm中的代码实现状态栏的显示。适用于希望解决此问题的游戏开发者。
3358

被折叠的 条评论
为什么被折叠?



