Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

iOS Status Bar

Use of the Status Bar

The status bar displays key information about the device.

The status bar is shown below:

iOS Tutorial

Methods to Hide the Status Bar

 [[UIApplication sharedApplication] setStatusBarHidden:YES];


Another Method to Hide the Status Bar

We can also hide the status bar by adding a row and, with the help of info.plist, selecting UIStatusBarHidden and setting its value to NO.

Add the custom method hideStatusbar to the class

It hides the status bar with animation and also adjusts the size we consider to occupy the status bar space.

 

-(void)hideStatusbar{

    [[UIApplication sharedApplication] setStatusBarHidden:YES 

    withAnimation:UIStatusBarAnimationFade];

    [UIView beginAnimations:@"Statusbar hide" context:nil];

    [UIView setAnimationDuration:0.5];

    [self.view setFrame:CGRectMake(0, 0, 320, 480)];

    [UIView commitAnimations];

}

Update viewDidLoad in ViewController.m as follows:

 

- (void)viewDidLoad

{

    [super viewDidLoad];

    // The method hideStatusbar called after 2 seconds

    [self performSelector:@selector(hideStatusbar) 

    withObject:nil afterDelay:2.0];

    // Do any additional setup after loading the view, typically from a nib.

}


Initial Output and Output After 2 Seconds

iOS Tutorial