在 ios 9 中隐藏状态栏 [英] Hide the status bar in ios 9

查看:27
本文介绍了在 ios 9 中隐藏状态栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ios 9 如何隐藏状态栏?

现在已弃用:

 [UIApplication sharedApplication] setStatusBarHidden:YES];

解决方案

Swift-3

 覆盖 var prefersStatusBarHidden: Bool {返回真}

我从

<小时>

旧答案!...

  1. didFinishLaunchingWithOptions

    中添加application.statusBarHidden

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {//在应用程序启动后覆盖自定义点.application.statusBarHidden = 是;返回是;}

并添加

  1. info.plist中添加这个View controller-based status bar appearance set NO

    查看基于控制器的状态栏外观 = NO

基于视图控制器的隐藏集

在视图控制器中添加方法.

目标 -C

- (BOOL)prefersStatusBarHidden {返回是;}

Swift 最多 2

override func prefersStatusBarHidden() ->布尔{返回真}

(GOOD) 2016.5.17 在 iOS 9.0 中运行良好.

更新答案

  1. 转到 Info.plist 文件
  2. 将鼠标悬停在其中一行上,将显示 (+) 和 (-) 按钮.
  3. 点击加号按钮添加新密钥
  4. 输入以大写 V 开头,第一个选项将自动成为基于视图控制器的状态栏外观.将其添加为 KEY.
  5. 将值设置为否"
  6. 转到你的 AppDelegate.m for Objective-C(快速语言:AppDelegate.swift)
  7. 在方法内添加代码

<小时>

对于 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 to var

  • 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 ! ...

  1. add application.statusBarHidden in didFinishLaunchingWithOptions

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    application.statusBarHidden = YES;
    return YES;
    }
    

and add

  1. in info.plist add this View controller-based status bar appearance set NO

    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

  1. Go to Info.plist file
  2. Hover on one of those lines and a (+) and (-) button will show up.
  3. Click the plus button to add new key
  4. Type in start with capital V and automatically the first choice will be View controller-based status bar appearance. Add that as the KEY.
  5. Set the VALUE to "NO"
  6. Go to you AppDelegate.m for Objective-C (for swift language: AppDelegate.swift)
  7. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆