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

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

问题描述

如何隐藏ios 9中的状态栏?



现已弃用:

  [UIApplication sharedApplication] setStatusBarHidden:YES]; 


解决方案

Swift-3

 覆盖var prefersStatusBarHidden:Bool {
return true
}

我从






旧答案! ...


  1. 在<$ c $中添加 application.statusBarHidden c> didFinishLaunchingWithOptions

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


并添加


  1. info.plist 添加此查看基于控制器的状态栏外观设置

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


基于视图控制器的隐藏设置



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



目标-C

   - (BOOL)prefersStatusBarHidden {
返回YES;
}

快到2

 覆盖func prefersStatusBarHidden() - > Bool {
返回true
}

(GOOD)2016.5.17在iOS中9.0工作得很好。



更新答案


  1. 转到Info.plist文件

  2. 将鼠标悬停在其中一行上,将显示一个(+)和( - )按钮。

  3. 单击加上按钮添加新密钥

  4. 输入以大写字母V 开头,第一个选择将自动查看基于控制器的状态栏外观。将其添加为KEY。

  5. 将VALUE设置为NO

  6. 为Objective-C转到AppDelegate.m( for swift语言:AppDelegate.swift

  7. 在方法中添加代码



< 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 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天全站免登陆