隐藏ios 9中的状态栏 [英] Hide the status bar in ios 9
问题描述
如何隐藏ios 9中的状态栏?
现已弃用:
[UIApplication sharedApplication] setStatusBarHidden:YES];
Swift-3
覆盖var prefersStatusBarHidden:Bool {
return true
}
我从
旧答案! ...
-
在<$ c $中添加
application.statusBarHidden
c> didFinishLaunchingWithOptions- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary * )launchOptions {
//在应用程序启动后覆盖自定义点。
application.statusBarHidden = YES;
返回YES;
}
并添加
-
info.plist
添加此查看基于控制器的状态栏外观
设置否
查看基于控制器的状态栏外观= NO
基于视图控制器的隐藏设置
在视图控制器中添加方法。
目标-C
- (BOOL)prefersStatusBarHidden {
返回YES;
}
快到2
覆盖func prefersStatusBarHidden() - > Bool {
返回true
}
(GOOD)2016.5.17在iOS中9.0工作得很好。
更新答案
- 转到Info.plist文件
- 将鼠标悬停在其中一行上,将显示一个(+)和( - )按钮。
- 单击加上按钮添加新密钥
- 输入以大写字母V 开头,第一个选择将自动查看基于控制器的状态栏外观。将其添加为KEY。
- 将VALUE设置为NO
- 为Objective-C转到AppDelegate.m( for swift语言:AppDelegate.swift )
- 在方法中添加代码
< hr>
对于Objective-C:
- (BOOL)应用程序:(UIApplication *)应用程序didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[application setStatusBarHidden:YES];
返回YES;
}
对于Swift :
func application(application:UIApplication,didFinishLaunchingWithOptions launchOptions:[NSObject:AnyObject]?) - > Bool {
application.statusBarHidden = true
返回true
}
How do you hide the status bar in ios 9?
This is now deprecated:
[UIApplication sharedApplication] setStatusBarHidden:YES];
Swift-3
override var prefersStatusBarHidden: Bool {
return true
}
I got the Information From Here
Change
func
tovar
Delete
()
Change
->
to:
This works because a computed variable has a getter function, so the function you were implementing before simply turns into the getter function
2016 onwards: simple Thing like
On your info.plist add the following two property for statusBar Hidden
View controller-based status bar appearance (Boolean: NO)
Status bar is initially hidden (Boolean: YES)
By Source
<key>UIStatusBarHidden</key>
<true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
or
Old answers ! ...
add
application.statusBarHidden
indidFinishLaunchingWithOptions
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. application.statusBarHidden = YES; return YES; }
and add
in
info.plist
add thisView controller-based status bar appearance
setNO
View controller-based status bar appearance = NO
viewcontroller based hidden set
Add method in your view controller.
Objective -C
- (BOOL)prefersStatusBarHidden {
return YES;
}
Swift upto 2
override func prefersStatusBarHidden() -> Bool {
return true
}
(GOOD) 2016.5.17 in iOS 9.0 worked nicely.
Updated Answer
- Go to Info.plist file
- Hover on one of those lines and a (+) and (-) button will show up.
- Click the plus button to add new key
- Type in start with capital V and automatically the first choice will be View controller-based status bar appearance. Add that as the KEY.
- Set the VALUE to "NO"
- Go to you AppDelegate.m for Objective-C (for swift language: AppDelegate.swift)
- Add the code, inside the method
For Objective-C:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[application setStatusBarHidden:YES];
return YES;
}
For Swift:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject:AnyObject]?) -> Bool {
application.statusBarHidden = true
return true
}
这篇关于隐藏ios 9中的状态栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!