在 ios 9 中隐藏状态栏 [英] Hide the status bar in ios 9
问题描述
ios 9 如何隐藏状态栏?
现在已弃用:
[UIApplication sharedApplication] setStatusBarHidden:YES];
Swift-3
覆盖 var prefersStatusBarHidden: Bool {返回真}
我从
<小时>旧答案!...
在
中添加didFinishLaunchingWithOptions
application.statusBarHidden
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {//在应用程序启动后覆盖自定义点.application.statusBarHidden = 是;返回是;}
并添加
在
info.plist
中添加这个View controller-based status bar appearance
setNO
查看基于控制器的状态栏外观 = NO
基于视图控制器的隐藏集
在视图控制器中添加方法.
目标 -C
- (BOOL)prefersStatusBarHidden {返回是;}
Swift 最多 2
override func prefersStatusBarHidden() ->布尔{返回真}
(GOOD) 2016.5.17 在 iOS 9.0 中运行良好.
更新答案
- 转到 Info.plist 文件
- 将鼠标悬停在其中一行上,将显示 (+) 和 (-) 按钮.
- 点击加号按钮添加新密钥
- 输入以大写 V 开头,第一个选项将自动成为基于视图控制器的状态栏外观.将其添加为 KEY.
- 将值设置为否"
- 转到你的 AppDelegate.m for Objective-C(快速语言:AppDelegate.swift)
- 在方法内添加代码
<小时>
对于 Objective-C:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {[应用程序 setStatusBarHidden:YES];返回是;}
<小时>
对于 Swift:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject:AnyObject]?) ->布尔{application.statusBarHidden = 真返回真}
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屋!