如何在ios 9中隐藏状态栏?
现在不推荐使用:
[UIApplication sharedApplication] setStatusBarHidden:YES];
斯威夫特3
override var prefersStatusBarHidden: Bool { return true }
更改func为var
func
var
删除 ()
()
更改->为:
->
:
之所以可行,是因为计算变量具有getter函数,因此您之前实现的函数只是变成了getter函数
2016年起:简单的事物
在您的info.plist上,为statusBar隐藏添加以下两个属性
查看基于控制器的状态栏外观(布尔值:否)
状态栏最初是隐藏的(布尔值:是)
按来源
<key>UIStatusBarHidden</key> <true/> <key>UIViewControllerBasedStatusBarAppearance</key> <false/>
要么
旧答案!…
application.statusBarHidden
didFinishLaunchingWithOptions
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch. application.statusBarHidden = YES; return YES; }
并添加
info.plist
View controller-based status bar appearance
NO
View controller-based status bar appearance = NO
基于ViewController的隐藏集
在您的视图控制器中添加方法。
目标-C
- (BOOL)prefersStatusBarHidden { return YES; }
迅捷至2
override func prefersStatusBarHidden() -> Bool { return true }
(良好)iOS 9.0中的2016.5.17运行良好。
更新的答案
对于Objective-C:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [application setStatusBarHidden:YES]; return YES; }
对于Swift:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject:AnyObject]?) -> Bool { application.statusBarHidden = true return true }