I want to hide the status bar at the click of a button. I have tried:
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
I have had no luck with this. Am I missing something?
I want to hide the status bar at the click of a button. I have tried:
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
I have had no luck with this. Am I missing something?
 
    
    The simple way is, go to the info.plist file. add row, "View controller-based status bar appearance" and set to NO. Check as an answer
 
    
    For toggling on and off in code only:
-(void)statusBarShouldHide:(bool)hide{
    hideStatusBar = hide;
    if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
        [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
    }
}
-(bool)prefersStatusBarHidden{
    return hideStatusBar;
}
called by:
[self statusBarShouldHide:true];
 
    
    if you wanna do this programmingly try this.
override the funtion
-(BOOL) prefersStatusBarHidden {
    return needHideStatusBar;
}
-(IBAction) checkStatus {
    // do your judgment here 
    needHideStatusBar = YES;
    if ([self 
        respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
        [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
    }
}
