Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

How do you hide the status bar in ios 9?

This is now deprecated:

 [UIApplication sharedApplication] setStatusBarHidden:YES];
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
586 views
Welcome To Ask or Share your Answers For Others

1 Answer

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

enter image description here


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
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...