Hide the status bar in ios 9
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
}
Runtime Hide / Show Status Bar iOS 9+
I hate to answer my own question, but after doing some digging, I found how to call the method manually. First, I created a BOOL variable that can be switched on the fly and then returned in the prefersStatusBarHidden method.
- (BOOL)prefersStatusBarHidden
{
return isStatusBarHidden;
}
Then, whenever I wanted to hide/show the status bar, I changed the value of isStatusBarHidden and forced the view to check if its staus bar needs to be updated like so:
isStatusBarHidden = NO;
[self setNeedsStatusBarAppearanceUpdate];
Works perfectly for me on devices running iOS9 and above.
Xcode 9.3. How to hide view statusbar in xib?
You need to set simulated metrics size to "Freeform". Next, you need to change the size of your view to some custom value. After that Xcode will hide the status bar.
iOS9: Custom UIWindow makes status bar disappear
Solved.
I needed to implement this method in the root view controller:
- (BOOL)prefersStatusBarHidden
{
return NO;
}
For some reasons, the root view controller in this UIWindow hid the status bar.
(though it should return NO by default, normally)
So instead of doing:
_envWindow.rootViewController = [[UIViewController alloc] init]; // added since iOS9 to avoid the assertion
I created my own view controller with prefersStatusBarHidden overridden.
Hide Status Bar in iOS 13
Step 1 :- add permission
Step 2 :- add the below code in desired view controller to hide the status bar .
override var prefersStatusBarHidden: Bool {
return true
}
NOTE :- if you don't set constrain properly after the hidden true / false you will have design issues , so take care about it ...:)
Related Topics
"No Such Module 'Alamofire'" Xcode Won't Recognize Alamofire Framework
Sharing an Image Between Two Viewcontrollers During a Transition Animation
Download and Cache Images in Uitableviewcell
Ios:Retrieve Rectangle Shaped Image from the Background Image
Fbsdkaccesstoken Currentaccesstoken Nil After Quitting App
What Impact Does Simulated Metrics Have
How to Logout User Using Facebook Authentication Using Swift and iOS
Various Itms Errors When Trying to Submit Archive to App Store
Uitextfield in Uialertcontroller (Border, Backgroundcolor)
Swift: Retrieving Text from a Uitextfield in a Custom Uitableviewcell and Putting It in an Array
Dismissing Both Uinavigation Views and Modal Views at Once Programmatically
Undefined Symbols for Architecture I386: "_Objc_Class_$_Zipexception", Referenced From: Error
Can't Connect Iboutlet in Interface Builder
Setting Constraints Programmatically
Get Date and Time from Apple Server
iOS 8 Keyboard Hides My Textview
How to Listen for All Notifications Sent to the iOS Nsnotificationcenter's Defaultcenter